Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple definition of 'testCases_metadata' #2

Closed
dib130030 opened this issue Aug 30, 2020 · 3 comments
Closed

multiple definition of 'testCases_metadata' #2

dib130030 opened this issue Aug 30, 2020 · 3 comments

Comments

@dib130030
Copy link

main.c:
#include "picotest.h"
PICOTEST_SUITE(mainSuite, testCases)
...

testcases.c:
#include "picotest.h"
PICOTEST_SUITE(testCases, testcase)
...

Because
_PICOTEST_SUITE_DECLARE_SUBTEST(_testName)
in picotest.h does not declare
PicoTestMetadata _PICOTEST_METADATA(_testName)
as 'extern' a PicoTestMetadata struct is created in each .obj file, which leads to conflict.

v.1.3.0 builds without error.

@dib130030 dib130030 changed the title multiple definition of `testCases_metadata' multiple definition of 'testCases_metadata' Aug 30, 2020
@fredericbonnet
Copy link
Owner

That's strange, I can't reproduce this behavior. What compiler are you using? Mine is the MSVC build tools on Windows, I've also tried the latest GCC on Linux and besides a few minor warnings (which I will fix in the next version) it works fine. Here are my sources:

main.c:

#include "picotest.h"
PICOTEST_SUITE(mainSuite, testCases);

void main() {
    mainSuite(NULL);
}

testcases.c:

#include <stdio.h>

#include "picotest.h"
PICOTEST_SUITE(testCases, testcase);

PICOTEST_CASE(testcase) {
    printf("testcase\n");
    PICOTEST_ASSERT(0);
}

@fredericbonnet
Copy link
Owner

Even though I couldn't reproduce the problem, you're right about PicoTestMetadata needing an extern declaration. The new release 1.41. hopefully fixes this problem, can you confirm that it works on your side?

@dib130030
Copy link
Author

I am using MSys64/MinGW-w64 on Windows with CLion. Release 1.41 fixes the issue, thanks! It also fixes
warning: initialization of 'const struct PicoTestMetadata **' from incompatible pointer type 'PicoTestMetadata **' [-Wincompatible-pointer-types]
in PICOTEST_SUITE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants