



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Based on slides by Jonathan Misurda
#include <stdio.h> #define MACRO int main() { #if defined MACRO printf(“this is printed\n”); #endif printf(“This is also printed\n”); return 0; }
#include <stdio.h> #define MACRO #undef MACRO int main() { #if defined MACRO printf(“this is not printed\n”); #endif printf(“This is printed\n”); return 0; }
Will refer to the same memory location
int x = 0; int f(int y) { return x+y; }
#include <stdio.h> extern int x; int f(int); int main() { x = 5; printf("%d", f(0)); return 0; }
static int x = 0; static int f(int y) { return x+y; }
#include <stdio.h> extern int x; int f(int); int main() { x = 5; printf("%d", f(0)); return 0; }
void *my_nextfit_malloc(int size); void my_free(void *ptr);
static MallocInfo *head; void *my_nextfit_malloc(int size){ static MallocInfo *current; ... } void my_free(void *ptr) { ... }
malloctest: mymalloc.o mallocdriver.o gcc – o malloctest mymalloc.o mallocdriver.o mymalloc.o: mymalloc.c mymalloc.h gcc – c mymalloc.c mallocdriver.o: mymalloc.h mallocdriver.c gcc – c mallocdriver.c
malloctest mymalloc.o mallocdriver.o mymalloc.c mymalloc.h mallocdriver.c