__EXPORT keyword

Hello,
I’ve just finished going through the tutorial to create a simple application :Redirecting... Page moved and I’ve now just started developing my own. To do so, I’ve just set up u working environment in Qtcreator (by opening the CMakeLists files and running the cmake command) to write my code in a nice IDE that offers all the functionalities I’m lookin for)

However, Qt Creator doesn’t recognize the __EXPORT command (it says “expected a declaration”). My questions are therefore the following :

  1. What is the use of the __EXPORT keyword ? Why do we need it ? What is it exactly (pre-compiler directive ?)
  2. Where is it defined ? In a header file ?
  3. How can I solve this problem in QtCreator ?

Thanks in advance for your replies.

I haven’t grasped the whole usefulness of the __EXPORT preprocessor directive but as no one has answered yet, I will try tro provide information about what I know so far about it.

__export is a type modifier keywords (extension to the C/C++ standard) that causes the function name to be exported to the linker : http://digitalmars.com/ctg/ctgLanguageImplementation.html. Not sure to understand that sentence in details though, and I don’t know what’s the difference between __EXPORT and __export if any.

If you want to get it working with C++, append it with extern "C". ,so you would write instead :
extern "C" __EXPORT int main(int argc, char *argv[]);

1 Like