Skip to content

Build failure with ODBC support due to PREFIX macro conflict between unixODBC and NumberFormatter.h #5010

@Hasoo

Description

@Hasoo

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:

  1. unixodbc_conf-x86_64.h defines PREFIX as a macro: #define PREFIX "/usr"
  2. Poco's NumberFormatter.h uses PREFIX as an enum value
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions