summaryrefslogtreecommitdiff
path: root/Modules/TestEndianess.c.in
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-08-07 09:09:45 -0400
committerBrad King <brad.king@kitware.com>2008-08-07 09:09:45 -0400
commitb8fc8b324d2e1b892d0b41cf3581226c210131d0 (patch)
tree5e36ef6e4586c5304ad69acc64e26779b426c842 /Modules/TestEndianess.c.in
parente58fab841fff0570d686200b916439cabe4deb83 (diff)
downloadcmake-b8fc8b324d2e1b892d0b41cf3581226c210131d0.tar.gz
ENH: Improve robustness of compiler INFO strings
Compiler INFO strings built at preprocessing time encode information that must appear as a string literal in the resulting binary. We must make sure the strings appear in the final binary no matter what compiler and flags are used. The previous implementation worked in most places but failed with the GNU linker's --gc-sections option which managed to discard the string. Instead we make the program return value depend on an element of the string indexed by a runtime program parameter, which absolutely requires the string to be present.
Diffstat (limited to 'Modules/TestEndianess.c.in')
-rw-r--r--Modules/TestEndianess.c.in13
1 files changed, 8 insertions, 5 deletions
diff --git a/Modules/TestEndianess.c.in b/Modules/TestEndianess.c.in
index 68094d4ac6..c924f7858a 100644
--- a/Modules/TestEndianess.c.in
+++ b/Modules/TestEndianess.c.in
@@ -10,11 +10,14 @@ const cmakeint16 info_little[] = {0x4854, 0x5349, 0x4920, 0x2053, 0x494c, 0x545
const cmakeint16 info_big[] = {0x5448, 0x4953, 0x2049, 0x5320, 0x4249, 0x4720, 0x454e, 0x4449, 0x414e, 0x2e2e, 0x0000};
#ifdef __CLASSIC_C__
-int main(){
- int ac;
- char*av[];
+int main(argc, argv) int argc; char *argv[];
#else
-int main(int ac, char*av[]){
+int main(int argc, char *argv[])
#endif
- return (&info_little[0] != &info_big[0]);
+{
+ int require = 0;
+ require += info_little[argc];
+ require += info_big[argc];
+ (void)argv;
+ return require;
}