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

Ask a Question

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.