Search code examples
c++freetdsunixodbc

Conflicting declaration ‘typedef int RETCODE’ error when using FreeTDS libraries


Am using FreeTDS libraries in order connect c++ to MSSQL, and am getting the below error on compilation.

In file included from pa_main.cpp:16:0: /usr/local/include/sybdb.h:120:13: error: conflicting declaration ‘typedef int RETCODE’ typedef int RETCODE;

In file included from /usr/include/sql.h:19:0, from pa_sql_db.h:16, from pa_main.cpp:11: /usr/include/sqltypes.h:268:33: note: previous declaration as ‘typedef short int RETCODE’ typedef signed short RETCODE;

What i understood is that unixodbc and freeTDS libraries using the same definition name RETCODE for different size int.

How can i avoid this situation ? Can anyone please suggest a workaround for this issue ?


Solution

  • You're dealing with two libraries that have backwards compatibility with C. C doesn't have namespaces, so they pollute the global namespace with their typedefs. I would recommend keeping your code for each library in separate translation units.