dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: __declspec: Can be compiled on GNU compilers?

  1. #1
    Join Date
    Jul 2017
    Posts
    45

    __declspec: Can be compiled on GNU compilers?

    Will the code below be able to be compiled on GNU compilers if the user defines DLL_IMPORT or DLL_EXPORT? Or gcc/g++ will complain about the __declspec?

    Code:
    #ifndef TEST_H
    #define TEST_H
    
    //Use this header for end user.
    #ifdef DLL_IMPORT
    #    define DLL_MACRO __declspec(dllimport)
    
    //Use this header for building the dll.
    #elif defined DLL_EXPORT
    #    define DLL_MACRO __declspec(dllexport)
    #else
    #	define DLL_MACRO
    #endif
    
    
    DLL_MACRO void print(const char *message);
    
    #endif

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,805

    Re: __declspec: Can be compiled on GNU compilers?


  3. #3
    Join Date
    Jul 2017
    Posts
    45

    Re: __declspec: Can be compiled on GNU compilers?

    So, it's Microsoft specific modifiers. I thought I saw somewhere that GNU actually supports specifically the __declspec, this is why i asked you.
    So in other words, when I'm building dll libraries I should use macros like the ones in my first post in order to control what code will get compiled for each platform, right? 99% I program in windows and visual studio but most of the times I want my code to be cross-compile able.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,805

    Re: __declspec: Can be compiled on GNU compilers?

    How about googling for "is __declspec supported in gnu"?

  5. #5
    Join Date
    Jul 2017
    Posts
    45

    Re: __declspec: Can be compiled on GNU compilers?

    Quote Originally Posted by Arjay View Post
    How about googling for "is __declspec supported in gnu"?
    I did before asking, but the answers wasn't clear.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)