Skip to content

Instantly share code, notes, and snippets.

@jclulow
Created August 25, 2012 06:23
Show Gist options
  • Select an option

  • Save jclulow/3461524 to your computer and use it in GitHub Desktop.

Select an option

Save jclulow/3461524 to your computer and use it in GitHub Desktop.
headers hooray
#include <stdlib.h>
#include <stdio.h>
#include "sigh.h"
int
main(void)
{
whatever(10, 15);
(whatever)(10, 15);
printf("whatever @ %p\n", whatever);
#undef whatever
whatever(10, 15);
printf("whatever @ %p\n", whatever);
return (0);
}
CC = gcc
xx: sigh.o sigh.h a.c
$(CC) -o xx sigh.o a.c
sigh.o: sigh.c
$(CC) -c -o sigh.o sigh.c
#include <stdio.h>
void
whatever(int a, int b)
{
printf("FUNCTION a %d b %d\n", a, b);
}
#ifndef __SIGH_H__
#define __SIGH_H__
extern int whatever(int a, int b);
#define whatever(a, b) \
do { \
printf("MACRO a %d b %d\n", (int)(a), (int)(b)); \
} while (0)
#endif /* __SIGH_H__ */
$ ./xx
MACRO a 10 b 15
FUNCTION a 10 b 15
whatever @ 0x104fd4dd0
FUNCTION a 10 b 15
whatever @ 0x104fd4dd0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment