[CDRIVER-4470] mongoc 1.23.0 compile tests require c99 standard Created: 07/Sep/22  Updated: 27/Oct/23  Resolved: 13/Sep/22

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.23.0
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: John Becker Assignee: Kevin Albertson
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-4136 Bump the minimum compilation standard... Closed

 Description   

Summary

test-mongoc-client-side-encryption.c.o fails to compile due to loop declaration requiring c99 standard.

Error message while running cmake:

[ 87%] Building C object src/libmongoc/CMakeFiles/test-libmongoc.dir/tests/test-mongoc-client-side-encryption.c.o
/home/jbecker/src/mongo_drivers/mongoc/mongo-c-driver-1.23.0/src/libmongoc/tests/test-mongoc-client-side-encryption.c: In function âtest_rewrap_with_separate_client_encryptionâ:
/home/jbecker/src/mongo_drivers/mongoc/mongo-c-driver-1.23.0/src/libmongoc/tests/test-mongoc-client-side-encryption.c:4922:4: error: âforâ loop initial declarations are only allowed in C99 mode
    for (size_t src_idx = 0u; src_idx < providers_len; ++src_idx) {
    ^
/home/jbecker/src/mongo_drivers/mongoc/mongo-c-driver-1.23.0/src/libmongoc/tests/test-mongoc-client-side-encryption.c:4922:4: note: use option -std=c99 or -std=gnu99 to compile your code
/home/jbecker/src/mongo_drivers/mongoc/mongo-c-driver-1.23.0/src/libmongoc/tests/test-mongoc-client-side-encryption.c:4923:7: error: âforâ loop initial declarations are only allowed in C99 mode
       for (size_t dst_idx = 0u; dst_idx < providers_len; ++dst_idx) {

Environment

OS version: Red Hat Enterprise Linux Server release 7.9 (Maipo)

C driver version: 1.23.0

Compiler: gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

cmake command:

/home/jbecker/src/mongo_drivers/mongoc/cmake-3.23.2-linux-x86_64/bin/cmake -G "Unix Makefiles" \
        -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF \
        -DCMAKE_INSTALL_PREFIX=/home/jbecker/src/mongo_drivers/mongoc/output \
        -DENABLE_SSL=OPENSSL \
        -DOPENSSL_SSL_LIBRARY=/home/jbecker/src/lib/libosi_ssl.so \
        -DOPENSSL_CRYPTO_LIBRARY=/home/jbecker/src/lib/libosi_crypto.so \
        -DOPENSSL_INCLUDE_DIR=/home/jbecker/src/include \
        -DENABLE_SASL=OFF \
        -DENABLE_SHM_COUNTERS=OFF \
        -DBUILD_VERSION=1.23.0

How to Reproduce

Run cmake build with the above versions



 Comments   
Comment by John Becker [ 13/Sep/22 ]

Adding "-DCMAKE_C_STANDARD=99" to the cmake arguments allows the driver to compile as expected.

Comment by Kevin Albertson [ 13/Sep/22 ]

Hello john.becker, thank you for the report.

The C driver has transitioned to testing builds with -std=c99.

There are tests in CI using gcc 4.8.4 on RHEL 7. Can you try passing -std=c99 to the build?

Generated at Wed Feb 07 21:21:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.