-
-
Save cfr/492623 to your computer and use it in GitHub Desktop.
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
syntax:glob | |
main | |
*.o | |
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
typedef void Image; | |
Image *make_image(int foo); | |
char access_pixel(Image *img, int r, int 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 <stdlib.h> | |
#include <image.h> | |
typedef struct { | |
int foo, bar; | |
} IplImage; | |
Image *make_image(int foo) { | |
IplImage *img = (Image *) malloc(sizeof(IplImage)); | |
if (!img) | |
return NULL; | |
img->foo = foo; | |
img->bar = foo + 14; | |
return img; | |
} | |
char access_pixel(Image *img, int r, int c) { | |
IplImage *iplimg = (IplImage *) img; | |
return iplimg->foo + r + 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 <stdio.h> | |
#include <image.h> | |
int main() { | |
Image *img = make_image(42); | |
if (!img) { | |
fprintf(stderr, "error: querying an image for 42 failed\n"); | |
return 1; | |
} | |
printf("access_pixel(img, 0, 0) = %d\n", access_pixel(img, 0, 0)); | |
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
SOURCES = image_cv.c main.c | |
OBJECTS = $(patsubst %.c,%.o,$(SOURCES)) | |
CC = gcc | |
CFLAGS = -std=c99 -Wall -Wextra -pedantic | |
INCLUDE = -I. | |
default: all | |
all: $(OBJECTS) main | |
main: main.o image_cv.o | |
gcc -o main main.o image_cv.o | |
image_cv.c: image.h | |
%.o: %.c | |
$(CC) -c -o $@ $(CFLAGS) $(INCLUDE) $< | |
clean: | |
rm -f $(OBJECTS) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment