Created
November 13, 2012 13:38
-
-
Save rmcgibbo/4065801 to your computer and use it in GitHub Desktop.
What is going on!!!!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #ifdef HEADER | |
| #include "lib.h" | |
| #endif | |
| int main(int argc, char* argv[]) { | |
| float a = 5.0; | |
| int b = 10; | |
| double c = 2.0; | |
| printf("in main, float a = %f\n", a); | |
| printf("in main, int b = %d\n", b); | |
| printf("in main, double c = %f\n", c); | |
| printf("Calling functions...\n"); | |
| g_float(a); | |
| g_int(b); | |
| g_double(c); | |
| return 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include "lib.h" | |
| void g_float(float a) { | |
| printf("In g_float, you passed a = %f\n", a); | |
| } | |
| void g_int(int b) { | |
| printf("In g_int, you passed b = %d\n", b); | |
| } | |
| void g_double(double c) { | |
| printf("In g_double, you passed c = %f\n", c); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef LIB_H | |
| #define LIB_H | |
| void g_float(float a); | |
| void g_int(int b); | |
| void g_double(double c); | |
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| all: | |
| gcc -DHEADER client.c lib.c -o withheader | |
| gcc client.c lib.c -o withoutheader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rmcgibbo@Roberts-MacBook-Pro-2 ~/local/mdtraj/ctest | |
| $ gcc --v | |
| Using built-in specs. | |
| Target: i686-apple-darwin11 | |
| Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2335.15~25/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2335.15~25/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1 | |
| Thread model: posix | |
| gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) | |
| rmcgibbo@Roberts-MacBook-Pro-2 ~/local/mdtraj/ctest | |
| $ make | |
| gcc -DHEADER client.c lib.c -o withheader | |
| gcc client.c lib.c -o withoutheader | |
| rmcgibbo@Roberts-MacBook-Pro-2 ~/local/mdtraj/ctest | |
| $ ./withheader | |
| in main, float a = 5.000000 | |
| in main, int b = 10 | |
| in main, double c = 2.000000 | |
| Calling functions... | |
| In g_float, you passed a = 5.000000 | |
| In g_int, you passed b = 10 | |
| In g_double, you passed c = 2.000000 | |
| rmcgibbo@Roberts-MacBook-Pro-2 ~/local/mdtraj/ctest | |
| $ ./withoutheader | |
| in main, float a = 5.000000 | |
| in main, int b = 10 | |
| in main, double c = 2.000000 | |
| Calling functions... | |
| In g_float, you passed a = 0.000000 | |
| In g_int, you passed b = 10 | |
| In g_double, you passed c = 2.000000 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it's not really that crazy, but it's still annoying.