10 likes | 137 Views
Multiple File Compilation and Linking . pthread.h. stdio.h. mars.h. venus.h. #ifndef STDIO_H #define STDIO_H #endif. #ifndef PTHREAD_H #define PTHREAD_H #endif. #ifndef MARS_HEADER #define MARS_HEADER #define MIN 1000 int doA(int nbr); #endif. #ifndef VENUS_HEADER
E N D
Multiple File Compilation and Linking pthread.h stdio.h mars.h venus.h #ifndef STDIO_H #define STDIO_H #endif #ifndef PTHREAD_H #define PTHREAD_H #endif #ifndef MARS_HEADER #define MARS_HEADER #define MIN 1000 int doA(int nbr); #endif #ifndef VENUS_HEADER #define VENUS_HEADER typedef struct { // fields } gravityType; void doB(char symbol); #endif programX.c #include <stdio.h> #include <pthread.h> #include “mars.h” #include “venus.h” main() { gravityType value; pthread_t threadID; int result; printf(“Hello”); result = doA(5); doB(‘d’); } // End main mars.c venus.c #include <stdio.h> #include “mars.h” int doA(int nbr) { return nbr * nbr; } // End doA #include “venus.h” #include <pthread.h> #define MAX 100 void doB(char symbol) { pthread_t threads[MAX]; } // End doB programX.o libc.a libpthread.a mars.o venus.o Object code file The Standard C Library Threads library Object code file Object code file a.out gcc programX.c mars.c venus.c Executable File