Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

deprecated - External header file ilcplexcpxconst.h causing causing compiler error

I have been sent code for a program built in C that uses a reinforcement learning algorithm. I need to modify it, yet I am having difficulties with compiling the code in the first place. Here are the outputs in CodeBlocks.

All errors come from one line of code in a header file, which is part of the IBM CPLEX include directory (includecplexcpxconst.h)

The line of code in question is as follows.

define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)

error messages are multiple types of syntax errors such as: error: expected identifier or '(' before ')' token

Each error has notes: to multiple lines of code in the file ilcplexcplex.h

I am using CodeBlocks in Windows 10 CPLEX version is 12.9.0

FULL ERROR MESSAGE

||=== Build: Release in SWEM2020 (compiler: GNU GCC Compiler) ===| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1194|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1194|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1200|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1200|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1231|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:UsersTingleOneDriveDocumentsCodingSWEM2020swemextras.h|16|error: conflicting types for 'trunc'| c:mingwincludemath.h|820|note: previous declaration of 'trunc' was here| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1194|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1194|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1200|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1200|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1231|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1231|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1237|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1237|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1242|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1242|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1597|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1597|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_genetic1.c||In function 'GeneticAlgorithm1':| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_genetic1.c|64|warning: too many arguments for format [-Wformat-extra-args]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_genetic1.c|67|warning: unused variable 'lostLoad' [-Wunused-variable]| C:UsersTingleOneDriveDocumentsCodingSWEM2020dlist.c|137|error: conflicting types for 'InsertInOrder_dlist'| C:UsersTingleOneDriveDocumentsCodingSWEM2020dlist.h|19|note: previous declaration of 'InsertInOrder_dlist' was here| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1231|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1237|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1237|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1242|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1242|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected ')' before 'deprecated'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1597|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcpxconst.h|243|error: expected identifier or '(' before ')' token| C:Program FilesIBMILOGCPLEX_Studio_Community129cplexincludeilcplexcplex.h|1597|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:UsersTingleOneDriveDocumentsCodingSWEM2020swemextras.h|16|error: conflicting types for 'trunc'| c:mingwincludemath.h|820|note: previous declaration of 'trunc' was here| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c||In function 'RFAlgorithm1':| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|183|warning: too many arguments for format [-Wformat-extra-args]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|185|warning: unused variable 'lostLoad' [-Wunused-variable]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c||In function 'Alg_MERwFirms_MustRun':| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|466|warning: unused variable 'lostLoad' [-Wunused-variable]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c||In function 'Alg_MERwFirms':| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|727|warning: too many arguments for format [-Wformat-extra-args]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|729|warning: unused variable 'lostLoad' [-Wunused-variable]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c||In function 'Alg_MERwFirmsSoftmax':| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|934|warning: too many arguments for format [-Wformat-extra-args]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|936|warning: unused variable 'lostLoad' [-Wunused-variable]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c||In function 'Alg_ERSpilloverwFirms':| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|1179|warning: too many arguments for format [-Wformat-extra-args]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|1181|warning: unused variable 'lostLoad' [-Wunused-variable]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c||In function 'Alg_ERSpilloverwFirmsSoftmax':| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|1393|warning: too many arguments for format [-Wformat-extra-args]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|1395|warning: unused variable 'lostLoad' [-Wunused-variable]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c||In function 'RFAlgorithm':| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|1573|warning: too many arguments for format [-Wformat-extra-args]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|1575|warning: unused variable 'lostLoad' [-Wunused-variable]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c||In function 'RFAlgorithmM':| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|1784|warning: too many arguments for format [-Wformat-extra-args]| C:UsersTingleOneDriveDocumentsCodingSWEM2020alg_rf.c|1786|warning: unused variable 'lostLoad' [-Wunused-variable]| ||=== Build failed: 27 error(s), 17 warning(s) (0 minute(s), 2 second(s)) ===|

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This answer is very similar to the one I gave here: C++: Cplex/cp optimizer makefile issues on project build using Clion with MinGW and g++ compiler

The CPLEX detailed system requirements (click on "Version 12.9.0" > "Windows" > "Prerequisites") show that Visual Studio 2015-2019 are the only supported compilers on Windows.

If we look at cpxconst.h, line 243 (from your error message), code in question we see:

#   if defined(_WIN32) && !defined(BUILD_CPXSTATIC)
#      define CPXLIBAPI __declspec(dllimport)
#      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
#      define CPXDEPRECATED(version) __declspec(deprecated)
...
#   endif

Based on this, it looks like your MinGW gcc has _WIN32 defined and it's defining CPXDEPRECATEDAPI in such a way that is only compatible with Microsoft Visual C.

You could replace the definition of CPXDEPRECATEDAPI with a no-op (i.e., edit cpxconst.h, like so:

#      define CPXDEPRECATEDAPI(version)

However, you are likely to just end up running into some other error down the line.

On Windows, you should really just use Visual Studio 2015 or above, or perhaps consider using the WSL.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...