Compiling C tests with C++ does not detect all problems
- Dominant language
- C++
- Stars
- 196
- Forks
- 34
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 11
Description
There is some C++ code in our C headers at ``sidre/core/SidreDataTypeIds.h.
using SIDRE_IndexType = int64_t;
Since we're compiling the C tests with C++, everything seemed ok.
I made a simple version of ``sidre_group_C.cpp`` as ``sidre_group_C_c.c`` with the addition of some lines
#include
#include
#define TEST(a, b) void a##_##b(void)
#define EXPECT_TRUE(a) assert(a)
#define EXPECT_FALSE(a) assert(!(a))
#define EXPECT_EQ(a, b) assert(a == b)
And a simple main program:
int main(int argc, char* argv[])
{
C_sidre_group_get_name();
C_sidre_group_create_destroy_view_and_buffer();
return 0;
}
Produces the error:
../../axom/sidre/core/SidreDataTypeIds.h:22:1: error: unknown type name 'using'; did you mean 'uint'?
using SIDRE_IndexType = int64_t;
^~~~~
I would find using the C compiler useful when testing Shroud changes to keep us honest.
There are a plethora of unit testing frameworks:
https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C
Contributor guide
Research direction
Start with sidre_group_C.cpp, the proposed sidre_group_C_c.c, and the C header sidre/core/SidreDataTypeIds.h. Review how the existing C tests are built, then run the tests with a C compiler; done means the C test sources compile and run independently of C++ and expose C-incompatible headers such as the shown using declaration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- build-system, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100