Compiler error using g++ from MinGW

Joined
Mar 16, 2016
Messages
1
Reaction score
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:
Joined
May 29, 2016
Messages
3
Reaction score
0
__declspec(dllimport deprecated) is not proper syntax. Additionally, __declspec(dllimport) is Microsoft compiler specific. You cannot use it with g++.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,692
Latest member
JenniferTi

Latest Threads

Top