Created
May 5, 2016 23:48
-
-
Save sparkprime/4cd03cd015d7ba78b82d0f6347177244 to your computer and use it in GitHub Desktop.
g++ pch problem
This file contains 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 HEADER_h | |
#define HEADER_h | |
#include <subheader.h> | |
int global_var; | |
static inline int f(int p) | |
{ | |
return p * p; | |
} | |
#endif |
This file contains 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 <cstdlib> | |
#include <iostream> | |
#include <header.h> | |
int main(void) | |
{ | |
std::cout << "global_var = " << global_var << std::endl; | |
std::cout << "f(10) = " << f(10) << std::endl; | |
std::cout << "global_var2 = " << global_var2 << std::endl; | |
std::cout << "g(10) = " << g(10) << std::endl; | |
return EXIT_SUCCESS; | |
} |
This file contains 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
%.h.gch: %.h | |
@mkdir -p out | |
g++ -Wall -Wextra -pedantic -x c++-header -I. $< -o out/$@ | |
main: main.cpp header.h.gch | |
@mkdir -p out | |
g++ -Wall -Wextra -pedantic -Winvalid-pch -I out $< -o out/$@ | |
clean: | |
rm -rfv out *~ |
This file contains 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 SUBHEADER_h | |
#define SUBHEADER_h | |
int global_var2; | |
static inline int g(int p) | |
{ | |
return 42 * p; | |
} | |
#endif |
Author
sparkprime
commented
May 5, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment