Tool/software: TI C/C++ Compiler
The following code does not compile using TI ARM compiler v17.3.0.STS or TI v5.2.8. I have not tried other versions.
// test.c
int getVal(void) { return 0; }
int will_compile(void) { ; int retVal = getVal(); return 0; }
#define MAKE_FUNC( funcName ) int funcName(void) { ; int retVal = getVal(); return 0; }
MAKE_FUNC(wont_compile)
// TI ARM compiler has the following complaints:
//
// >> Compilation failure
// source/subdir_rules.mk:21: recipe for target 'source/test.obj' failed
// "../source/test.c", line 9: warning #994-D: missing return statement at end of non-void function "wont_compile"
// "../source/test.c", line 9: error #68: expected a "}"
// "../source/test.c", line 9: error #60: function call is not allowed in a constant expression
// "../source/test.c", line 9: error #171: expected a declaration
// "../source/test.c", line 9: error #171: expected a declaration
// At end of source: warning #12-D: parsing restarts here after previous syntax error
// 4 errors detected in the compilation of "../source/test.c".
// gmake: *** [source/test.obj] Error 1
Here is the pre-processed output:
int getVal(void) { return 0; }
int will_compile(void) { ; int retVal = getVal(); return 0; }
int wont_compile(void) { ; int retVal = getVal(); return 0; }
The pre-processed output compiles just file if saving it as a .c file.
--thx
test.c:
// test.c
int getVal(void) { return 0; }
int will_compile(void) { ; int retVal = getVal(); return 0; }
#define MAKE_FUNC( funcName ) int funcName(void) { ; int retVal = getVal(); return 0; }
MAKE_FUNC(wont_compile)
// TI ARM compiler has the following complaints:
//
// >> Compilation failure
// source/subdir_rules.mk:21: recipe for target 'source/test.obj' failed
// "../source/test.c", line 9: warning #994-D: missing return statement at end of non-void function "wont_compile"
// "../source/test.c", line 9: error #68: expected a "}"
// "../source/test.c", line 9: error #60: function call is not allowed in a constant expression
// "../source/test.c", line 9: error #171: expected a declaration
// "../source/test.c", line 9: error #171: expected a declaration
// At end of source: warning #12-D: parsing restarts here after previous syntax error
// 4 errors detected in the compilation of "../source/test.c".
// gmake: *** [source/test.obj] Error 1
test.pp.c:
int getVal(void) { return 0; }
int will_compile(void) { ; int retVal = getVal(); return 0; }
int wont_compile(void) { ; int retVal = getVal(); return 0; }
Note that the forum interface will not let me upload a ".pp" file, so I have renamed it to a ".pp.c" file, but, other than renaming, that file is exactly as the pre-processor created it.