GeezerVison is showing github.com — Add malloc.h into StandardCLibrary.h. by ahuo-dev · Pull Request #1835 · cpputest/cpputest
Conversation
Add malloc.h into StandardCLibrary.h. Some C code include malloc.h for malloc func.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
thetic
commented
Jan 2, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Per the standard, malloc is declared in stdlib.h1 which is already included.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@ahuo-dev Could you share what environment you were trying to solve what problem, then we can look at whether this is the best fix.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Ok, but the include of #malloc.h in the CommonDef.h shouldn't need to trigger you to include it in the SatndardCLibrary.h, right?
Could you share what the compile error is that you are getting?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Ok, but the include of #malloc.h in the CommonDef.h shouldn't need to trigger you to include it in the SatndardCLibrary.h, right?
Could you share what the compile error is that you are getting?
Compile error message :
"nclude/CppUTest/MemoryLeakDetectorMallocMacros.h:36:47: error: expected declaration specifiers or ‘...’ before string constant
36 | #define malloc(a) cpputest_malloc_location(a, FILE, LINE)"
and run command "gcc -E " to expand all macro. I see malloc function prototype expand to cpputest_malloc_location, like this :
extern void *
38 "/usr/include/malloc.h"
cpputest_malloc_location(
38 "/usr/include/malloc.h" 3 4
38 "/usr/include/malloc.h"
, "/usr/include/malloc.h", 38)
38 "/usr/include/malloc.h" 3 4
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__))
__attribute__ ((__alloc_size__ (1))) ;
Normally it should be like this:
extern void *malloc (size_t __size) __THROW attribute_malloc
attribute_alloc_size ((1)) __wur;
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.