Created
February 15, 2012 04:28
-
-
Save sw17ch/1833197 to your computer and use it in GitHub Desktop.
bad_way.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
#include "interface.h" | |
void initialize(void) | |
{ | |
puts("Common Initialize\n"); | |
#if defined(PLATFORM_A) | |
puts("Initialize A\n"); | |
#elif defined(PLATFORM_B) | |
puts("Initialize B\n"); | |
#else | |
#error "Invalid platform." | |
#endif | |
} | |
void do_stuff(void) | |
{ | |
puts("Common Do Stuff\n"); | |
#if defined(PLATFORM_A) | |
puts("Do Stuff A\n"); | |
#elif defined(PLATFORM_B) | |
puts("Do Stuff B\n"); | |
#else | |
#error "Invalid platform." | |
#endif | |
} | |
void cleanup(void) | |
{ | |
puts("Common Cleanup\n"); | |
#if defined(PLATFORM_A) | |
puts("Cleanup A\n"); | |
#elif defined(PLATFORM_B) | |
puts("Cleanup B\n"); | |
#else | |
#error "Invalid platform." | |
#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
#include <stdio.h> | |
#include "common.h" | |
void common_initialize(void) | |
{ | |
puts("Common Initialize\n"); | |
} | |
void common_do_stuff(void) | |
{ | |
puts("Common Do Stuff\n"); | |
} | |
void common_cleanup(void) | |
{ | |
puts("Common Cleanup\n"); | |
} |
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 __COMMON__ | |
#define __COMMON__ | |
void common_initialize(void); | |
void common_do_stuff(void); | |
void common_cleanup(void); | |
#endif /* __COMMON__ */ |
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 __INTERFACE__ | |
#define __INTERFACE__ | |
void initialize(void); | |
void do_stuff(void); | |
void cleanup(void); | |
#endif /* __INTERFACE__ */ |
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 "interface.h" | |
int main(int argc, char * argv[]) | |
{ | |
initialize(); | |
do_stuff(); | |
cleanup(); | |
return 0; | |
} |
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 "common.h" | |
#include "interface.h" | |
void initialize(void) | |
{ | |
common_initialize(); | |
puts("Initialize A\n"); | |
} | |
void do_stuff(void) | |
{ | |
common_do_stuff(); | |
puts("Do Stuff A\n"); | |
} | |
void cleanup(void) | |
{ | |
common_cleanup(); | |
puts("Cleanup A\n"); | |
} |
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 "common.h" | |
#include "interface.h" | |
void initialize(void) | |
{ | |
common_initialize(); | |
puts("Initialize B\n"); | |
} | |
void do_stuff(void) | |
{ | |
common_do_stuff(); | |
puts("Do Stuff B\n"); | |
} | |
void cleanup(void) | |
{ | |
common_cleanup(); | |
puts("Cleanup B\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment