The code example is very simple.
#include <stdio.h>
int main() {
printf("hello, world");
}
- Generate the .i file.
gcc -E test.cpp -o test.cpp.ii
- generate .o files for .i files
clang++ -c test.cpp.ii -o test.cpp.o
The following error message is displayed.
In file included from test.cpp:1:
/usr/include/stdio.h:189:48: error: '__malloc__' attribute takes no arguments
__attribute__ ((__malloc__)) __attribute__ ((__malloc__ (fclose, 1))) ;
^
/usr/include/stdio.h:201:49: error: '__malloc__' attribute takes no arguments
__attribute__ ((__malloc__)) __attribute__ ((__malloc__ (fclose, 1))) ;
^
/usr/include/stdio.h:223:77: error: use of undeclared identifier '__builtin_free'; did you mean '__builtin_frexp'?
noexcept (true) __attribute__ ((__malloc__)) __attribute__ ((__malloc__ (__builtin_free, 1)));
^
/usr/include/stdio.h:223:77: note: '__builtin_frexp' declared here
/usr/include/stdio.h:223:65: error: '__malloc__' attribute takes no arguments
noexcept (true) __attribute__ ((__malloc__)) __attribute__ ((__malloc__ (__builtin_free, 1)));
btw, When using gcc to generate .o files from .i files, everything works fine.
Specifically, my question is:
- attribute ((malloc)) is a feature unique to GCC support?
- In this case, how to make clang generate .o files correctly