-
Notifications
You must be signed in to change notification settings - Fork 1.1k
CJSON_AS4CPP incompatable with original cJSON #1829
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
Comments
Hi @scottpakula , Also, and this is more for the benefit of anybody who might also get this issue before we come up with a solution, have you thought of any workarounds or are you currently blocked by this change? |
Thank for very much for the reply. That is correct, I have existing projects that have linked cJSON and the aws-sdk-cpp just fine for a while, but this recent change has broken my ability to compile, when these two libraries are used together. My workaround at the moment is to simply stick with 1.9.96. The cause of this issue is that when cJSON.h was modified it also updated the header guard from:
to:
However, we get a redefinition error for the below data structure since typedef struct cJSON exists in both the original implementation of cJSON and the modified version of cJSON within the aws-sdk-cpp, and the header guards are different therefore cJSON will be defined twice.
Now the reason why this was changed according to the notes says: In my opinion, I would recommend that this change (2848c45) to cJSON within the aws-sdk-cpp be reverted and reviewed further. I'm not sure the clashes were being encountered; however, having to rename all the functions within the cJSON library seems a bit of an extreme fix. The way that the changes were made will cause conflicts with other projects that also use cJSON within their applications for the reasons noted above. Let me know if this makes more sense and again thank you for your help. |
It looks like an update was made that reverted the change. I will close this issue. |
|
@scottpakula where did you see this update? Looks like the current version still have this problem. |
@italorossi you are correct, the issue still exists so I'm re-opening the issue. The way that I am working around this issue is by patching cJSON.h within the aws-sdk-cpp as part of my build process, and including both guards, and I got confused forgetting that I had this patch in place.
This would be a quick fix, so that things continue to build, but this is a less than ideal solution to the problem as the library has been heavily forked within the aws-sdk-cpp project. This is making an assumption that typedef struct cJSON is the same in both projects, but now it's hard to know if that would/would not be true. Some possible solutions might be:
|
Hi @scottpakula, this will be solved as part of #1888 by depending directly in cJSON. |
I guess this is still open? I am experiencing the same issue described, using 1.11.143 |
Yes, this still open. We have yet to complete the changes in #1888 |
Any updates? |
Sorry, but no updates. We are still working on this but I don't have a timeline for when this will be fixed |
I just encountered this also. No updates? |
The issue still persists in the latest version of library. are there any updates on a fix? |
Not sure if it helps but the workaround that I posted in 2021 still works. I'm still doing that |
Yes your workaround is still working fine. I just thought there might be an official fix for this in the meantime. |
I had recently upgraded from aws-sdk-cpp 1.9.96 to 1.9.160, and in this update, the cJSON.h has been customized to redefine many functions to use the CJSON_AS4CPP convention.
The previous implementation looks like this:
https://github.com/aws/aws-sdk-cpp/blob/b7ad1b3e405ec730f1247f049bd700e7a3666622/aws-cpp-sdk-core/include/aws/core/external/cjson/cJSON.h
The current implementation looks like this:
https://github.com/aws/aws-sdk-cpp/blob/main/aws-cpp-sdk-core/include/aws/core/external/cjson/cJSON.h
For projects that are using cJSON.h as well as linking aws-sdk-cpp, this is a breaking change as the structure of cJSON becomes redefined because the header guards used by the original library are different.
To reproduce this issue, simply use the original library within an application that is also using the aws-sdk-cpp.
https://github.com/DaveGamble/cJSON
To avoid this issue, it would be ideal if the typedef struct cJSON within the aws-cpp-sdk was renamed to something like cJSON_AS4CPP.
The text was updated successfully, but these errors were encountered: