Environment
- OS: Rocky Linux 9.6 (Blue Onyx)
- GCC: 11.5.0 20240719 (Red Hat 11.5.0-5)
- unixODBC: 2.3.9-4.el9.x86_64
- unixODBC-devel: 2.3.9-4.el9.x86_64
- Poco version: 1.14.2-release
Problem Description
When building Poco library with ODBC support on Rocky Linux 9, compilation fails due to a macro name conflict between unixODBC and Poco's NumberFormatter.h.
Error Details
curl -LO https://github.com/pocoproject/poco/archive/refs/tags/poco-1.14.2-release.tar.gz &&
tar xzvf poco-1.14.2-release.tar.gz &&
cd poco-poco-1.14.2-release &&
./configure --omit=Data/MySQL,Data/PostgreSQL,Data/SQLite --no-tests --no-samples --prefix=$HOME/workspace/packages/poco --odbc-lib=/usr/lib64 --odbc-include=/usr/include &&
make -j$(nproc) &&
make install
The compilation fails with the following error:
poco-poco-1.14.2-release/Foundation/include/Poco/NumberFormatter.h:51:17: error: expected identifier before string constant
51 | PREFIX = 1 << 0,
| ^~~~~~
Root Cause
The issue occurs because:
- unixodbc_conf-x86_64.h defines PREFIX as a macro: #define PREFIX "/usr"
- Poco's NumberFormatter.h uses PREFIX as an enum value
- This creates a conflict when ODBC headers are included
Workaround
The issue can be resolved by adding #undef PREFIX after including ODBC headers in Data/ODBC/include/Poco/Data/ODBC/Unicode.h:
#include <sqlext.h>
#include <sqltypes.h>
#include <sqlucode.h>
#ifdef PREFIX
#undef PREFIX
#endif
Suggested Fix
Consider adding the #undef PREFIX directive to prevent this macro conflict, or use a more specific name for the enum value in NumberFormatter.h to avoid potential conflicts with system headers.
Environment
Problem Description
When building Poco library with ODBC support on Rocky Linux 9, compilation fails due to a macro name conflict between unixODBC and Poco's NumberFormatter.h.
Error Details
The compilation fails with the following error:
Root Cause
The issue occurs because:
Workaround
The issue can be resolved by adding #undef PREFIX after including ODBC headers in Data/ODBC/include/Poco/Data/ODBC/Unicode.h:
Suggested Fix
Consider adding the #undef PREFIX directive to prevent this macro conflict, or use a more specific name for the enum value in NumberFormatter.h to avoid potential conflicts with system headers.