Skip to content

Instantly share code, notes, and snippets.

@cfr
Forked from vlasovskikh/.hgignore
Created July 27, 2010 18:24

Revisions

  1. cfr revised this gist May 27, 2011. 1 changed file with 0 additions and 21 deletions.
    21 changes: 0 additions & 21 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -1,21 +0,0 @@
    SOURCES = image_cv.c main.c
    OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
    CC = gcc
    CFLAGS = -std=c99 -Wall -Wextra -Werror -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)

  2. cfr revised this gist Jul 27, 2010. 2 changed files with 3 additions and 3 deletions.
    4 changes: 2 additions & 2 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    SOURCES = image_cv.c main.c
    OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
    CC = gcc
    CFLAGS = -std=c99 -Wall -Wextra -Werror -pedantic
    CC = gcc
    CFLAGS = -std=c99 -Wall -Wextra -Werror -pedantic
    INCLUDE = -I.

    default: all
    2 changes: 1 addition & 1 deletion main.c
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ int main() {
    struct {
    char c;
    } a = {'a'};
    printf("access_pixel(img, 0, 0) = %d\n", access_pixel(&a, 0, 0));
    printf("access_pixel(img, 0, 1) = %d\n", access_pixel(&a, 0, 0));
    return 0;
    }

  3. @vlasovskikh vlasovskikh revised this gist Jul 11, 2010. 3 changed files with 4 additions and 4 deletions.
    2 changes: 1 addition & 1 deletion Makefile
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    SOURCES = image_cv.c main.c
    OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
    CC = gcc
    CFLAGS = -std=c99 -Wall -Wextra -pedantic
    CFLAGS = -std=c99 -Wall -Wextra -Werror -pedantic
    INCLUDE = -I.

    default: all
    2 changes: 1 addition & 1 deletion image.h
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    typedef void Image;
    typedef int Image;

    Image *make_image(int foo);
    char access_pixel(Image *img, int r, int c);
    4 changes: 2 additions & 2 deletions image_cv.c
    Original file line number Diff line number Diff line change
    @@ -6,12 +6,12 @@ typedef struct {
    } IplImage;

    Image *make_image(int foo) {
    IplImage *img = (Image *) malloc(sizeof(IplImage));
    IplImage *img = (IplImage *) malloc(sizeof(IplImage));
    if (!img)
    return NULL;
    img->foo = foo;
    img->bar = foo + 14;
    return img;
    return (Image *) img;
    }

    char access_pixel(Image *img, int r, int c) {
  4. @vlasovskikh vlasovskikh revised this gist Jul 11, 2010. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion main.c
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,10 @@ int main() {
    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));
    struct {
    char c;
    } a = {'a'};
    printf("access_pixel(img, 0, 0) = %d\n", access_pixel(&a, 0, 0));
    return 0;
    }

  5. @vlasovskikh vlasovskikh revised this gist Jul 11, 2010. 5 changed files with 63 additions and 1 deletion.
    4 changes: 4 additions & 0 deletions .hgignore
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    syntax:glob
    main
    *.o

    21 changes: 21 additions & 0 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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)

    5 changes: 4 additions & 1 deletion image.h
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,5 @@
    typedef Image void;
    typedef void Image;

    Image *make_image(int foo);
    char access_pixel(Image *img, int r, int c);

    21 changes: 21 additions & 0 deletions image_cv.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #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;
    }

    13 changes: 13 additions & 0 deletions main.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #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;
    }

  6. vlasovskikh created this gist Jul 11, 2010.
    2 changes: 2 additions & 0 deletions image.h
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    typedef Image void;
    char access_pixel(Image *img, int r, int c);