You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Issue:**
aws-crt-cpp fails while building test files, if user sets `CXXFLAGS=-std=c++11`.
This was happening in [aws-crt-builder's CI](https://github.com/awslabs/aws-crt-builder/blob/160150b3abcbfad9a21641ace57e68e0185329ad/.github/workflows/sanity-test.yml#L229), and [this PR](awslabs/aws-crt-builder#319) started failing because of it.
**Diagnosis:**
Here's what I found:
* Our tests rely on the [`## __VA_ARGS__`](https://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html) compiler extension, due to its usage within our [`ASSERT(...)`](https://github.com/awslabs/aws-c-common/blob/d80b00560f0ebb441538b3ab40192a242afeaa80/include/aws/testing/aws_test_harness.h#L96) macros.
* We use it so that custom failure messages are optional
* Apparently, this compiler extension is widely supported, because this code has been here for 7 years, and we never realized it was problematic
* CMake defaults to building with compiler extensions ON
* With extensions ON, the `-std=gnu99` compiler flag will be used, instead of `-std=c99` flag
* Our tests fail to compile if user changes does something that makes compiler extensions OFF by default. This can be done in a variety of ways, including...
* `CXXFLAGS=-std=c++11`
* `CFLAGS=-std=c99`
* `CMAKE_C_EXTENSIONS_DEFAULT=OFF`
This leaves us with two options:
1) Ensure compiler extensions are enabled when building tests
2) Change the ASSERT(...) macros, so they don't rely on the extension.
I investigated changing the ASSERT(...) macros, having differently named ASSERTF(...) macros for custom messages, but this was a massive breaking change for our downstream libraries that use these macros. I'll leave it in this [less-macro-magic](https://github.com/awslabs/aws-c-common/tree/less-macro-magic) branch, that we can pick up if we ever need to do this in the future.
I'm going to go with the less disruptive option 1 fix for now...
**Description of changes:**
* Ensure compiler extensions are turned ON for tests
* Ensure public headers are not relying on compiler extensions
0 commit comments