Compiler error using g++ from MinGW

Discussion in 'C Programming' started by Ptaclusp, Mar 16, 2016.

  1. Ptaclusp

    Ptaclusp

    Joined:
    Mar 16, 2016
    Messages:
    1
    Likes Received:
    0
    Using g++ from MinGW trying to compile some programme causes errors.

    MWE:

    #include <cstdlib>
    #define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)

    CPXDEPRECATEDAPI(12040000) void CPXopenCPLEX();

    using namespace std;

    int main(int argc, char** argv) {

    return 0;
    }

    Then compiling with
    g++ -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp

    gives the error messages
    (g++ version 5.3.0 from MinGW_w64):

    main.cpp:2:56: error: expected ')' before 'deprecated'
    #define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
    ^
    main.cpp:4:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
    CPXDEPRECATEDAPI(12040000) void CPXopenCPLEX();
    ^
    main.cpp:2:56: error: expected ')' before 'deprecated'
    #define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
    ^
    main.cpp:4:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
    CPXDEPRECATEDAPI(12040000) void CPXopenCPLEX();
    ^
    main.cpp:4:46: error: declaration does not declare anything [-fpermissive]
    CPXDEPRECATEDAPI(12040000) void CPXopenCPLEX();


    or with g++ version 4.7.2 from MinGW (32 bit):

    main.cpp:4:1: error: expected ')' before 'deprecated'
    main.cpp:4:1: error: expected ')' before 'deprecated'
    main.cpp:4:1: error: 'deprecated' does not name a type


    Why do I get these errors? How to get rid of them?
     
    Last edited: Mar 16, 2016
    Ptaclusp, Mar 16, 2016
    #1
    1. Advertisements

  2. Ptaclusp

    0xDEAD10CC

    Joined:
    May 29, 2016
    Messages:
    3
    Likes Received:
    0
    __declspec(dllimport deprecated) is not proper syntax. Additionally, __declspec(dllimport) is Microsoft compiler specific. You cannot use it with g++.
     
    0xDEAD10CC, May 29, 2016
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Yan
    Replies:
    0
    Views:
    1,590
  2. Ram
    Replies:
    0
    Views:
    3,494
  3. Sam Smith
    Replies:
    0
    Views:
    1,687
    Sam Smith
    Oct 18, 2004
  4. dbrown2@yahoo.com

    Win2k and mingw gnu compiler with Python 2.3.2?

    dbrown2@yahoo.com, Oct 22, 2003, in forum: Python
    Replies:
    4
    Views:
    619
    John J. Lee
    Oct 25, 2003
  5. Ilias Lazaridis
    Replies:
    213
    Views:
    3,950
    Markus Wankus
    Feb 24, 2005
  6. mike
    Replies:
    3
    Views:
    3,100
  7. Gerwin
    Replies:
    1
    Views:
    599
    Erik Wikström
    Dec 9, 2007
  8. xeno fears
    Replies:
    1
    Views:
    792
    Martin v. Löwis
    Oct 4, 2009
Loading...