Last active
May 26, 2018 12:29
-
-
Save Benedikt1992/05d01948ed1638e656b1dfbad244337c to your computer and use it in GitHub Desktop.
External Header example
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
main |
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 SAMPLE_CONF_H | |
#define SAMPLE_CONF_H | |
#define FIRST_MACRO 1 | |
#endif //SAMPLE_CONF_H |
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 SAMPLE_HELLO_CITY_H | |
#define SAMPLE_HELLO_CITY_H | |
#define SECOND_MACRO 1 | |
#endif //SAMPLE_HELLO_CITY_H |
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 "hello_city.h" | |
#include "hello_world.h" | |
#include <stdio.h> | |
#if FIRST_MACRO | |
#if SECOND_MACRO | |
void hello_world(void) { | |
printf("Hello, World!\n"); | |
} | |
#endif //SECOND_MACRO | |
#endif //FIRST_MARCO | |
#ifndef FIRST_MACRO | |
void hello_world(void) { | |
printf("Shame on you!\n"); | |
} | |
#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
// | |
// Created by username on 5/26/18. | |
// | |
#ifndef SAMPLE_HELLO_WORLD_H | |
#define SAMPLE_HELLO_WORLD_H | |
/* PROJECT_CONF_H might be defined in the project Makefile */ | |
#ifdef PROJECT_CONF_H | |
#include PROJECT_CONF_H | |
#endif /* PROJECT_CONF_H */ | |
void hello_world(); | |
#endif //SAMPLE_HELLO_WORLD_H |
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 <stdio.h> | |
#include "hello_world.h" | |
int main() { | |
hello_world(); | |
return 0; | |
} |
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
main: main.o hello_world.o | |
gcc -o main main.o hello_world.o | |
rm *.o | |
main.o: main.c hello_world.h | |
gcc -c main.c | |
hello_world.o: hello_world.c hello_world.h hello_city.h | |
gcc -DPROJECT_CONF_H=\"conf.h\" -c hello_world.c | |
clean: | |
rm main | |
all: main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment