- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have below code in Linux which is working fine without any error. Since __declspec(dllexport) and __declspec(dllimport) are windows specific then why compiler is not complaining about it?
code in .hpp is as below.
#ifdef EXPORT_MY_DLL
#define MYEXPORTER __declspec(dllexport)
#else
#define MYEXPORTER __declspec(dllimport)
#endif
MYEXPORTER bool isInitialised();
and code in cpp is as below.
MYEXPORTER bool isInitialised(){
return true;
}
Please help me to understand this as I have mostly worked on windows so keen to understand why there is no warning or error.
Thanks.
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Which compiler version and how (command line) do you use? Have you included the header file?
I easily get the error message
$ icpc test.cpp
In file included from test.cpp(1):
test.hpp(11): error #1292: unknown attribute "dllimport"
MYEXPORTER bool isInitialised();
^
test.cpp(3): error #1292: unknown attribute "dllimport"
MYEXPORTER bool isInitialised(){
^
compilation aborted for test.cpp (code 2)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can see you have got error but I am still not sure why I am not getting this error. I am using CMAKE with the 18 version of intel compiler. yes i have include my header in cpp file.
I have also written a test program to do something like below.
test.hpp
__declspec(dllexport) bool isInitialised();
test.cpp
__declspec(dllexport) bool isInitialised(){
return true;
}
The above code also working fine. now I am only getting error i misspell as below.
__declssdfdspec(dllexport) bool isInitialised(){
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok. error is not coming due to the compiler option -wd1292 which has been used in CMAKE. but should I be using it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
naddy wrote:
Ok. error is not coming due to the compiler option -wd1292 which has been used in CMAKE. but should I be using it?
This is exactly what -wd1292 option does - disables error #1292 :)
So, it is obvious you don't get an error/warning.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page