c 宏 helloworld
a.h
#ifndef A_H_
#define A_H_
typedef long int int4;
#define MAX( x, y ) ( ((x) > (y)) ? (x) : (y) )
#define g_new(structs) malloc(sizeof(structs))
int
add_count (int a, int b);
#endif
a.c
#include "a.h"
int
add_count (int a, int b)
{
return a + b;
} /* ----- end of function add_count ----- */
main.c
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "a.h"
typedef struct PageStr PageStrCPN;
struct PageStr
{
char* p_ch_data;
int a;
int b;
};
int
main ( int argc, char *argv[] )
{
int4 a = 10 , b = 100;
char *c = g_new(PageStrCPN);
((PageStrCPN*)c)->a = 10;
printf ("\nProgram %d\n\n", ((PageStrCPN*)c)->a );
printf ("\nProgram %d\n\n",(int)MAX(a, b) );
free(c);
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */
编译:Makefile
all:main
main:main.c a.c
gcc -g -Wall -O0 main.c a.c -o main
******output*******
Program 10
Program 100