Skip to content

Commit

Permalink
Compile with -Wall
Browse files Browse the repository at this point in the history
I had to fix a few warnings in the code.
  • Loading branch information
guillaumechereau committed Jun 11, 2015
1 parent 0532589 commit 4322348
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -4,5 +4,6 @@
all:
g++ -o test_turtle \
tests/turtle.c noc_turtle.c \
-Wall \
-O0 -fsanitize=address -g \
-I ./ -lglfw -lGLEW -lGL -lm -lasan
8 changes: 4 additions & 4 deletions noc_turtle.c
Expand Up @@ -510,10 +510,10 @@ void noctt_rsquare(const noctt_turtle_t *turtle, float c)
r = max((sm - c) / 2, 0);
rx = r / sx;
ry = r / sy;
const float d[][2] = {{+0.5 - rx, +0.5 - ry},
{-0.5 + rx, +0.5 - ry},
{-0.5 + rx, -0.5 + ry},
{+0.5 - rx, -0.5 + ry}};
const float d[][2] = {{+0.5f - rx, +0.5f - ry},
{-0.5f + rx, +0.5f - ry},
{-0.5f + rx, -0.5f + ry},
{+0.5f - rx, -0.5f + ry}};
poly = (noctt_vec3_t*)calloc(4 * n, sizeof(*poly));
for (i = 0, a = 0; i < 4 * n; i++) {
aa = a * M_PI / (2 * (n - 1));
Expand Down
21 changes: 18 additions & 3 deletions noc_turtle.h
Expand Up @@ -488,6 +488,7 @@ enum {
NOCTT_FLAG_DONE = 1 << 0,
NOCTT_FLAG_JUST_CLONED = 1 << 1,
NOCTT_FLAG_WAITING = 1 << 2,
NOCTT_FLAG_BLOCK_DONE = 1 << 3,
};

#define NOCTT_OP_START FLT_MAX
Expand Down Expand Up @@ -559,15 +560,18 @@ enum {
NOCTT_PRIMITIVE_(noctt_poly(&turtle_, n, p), __VA_ARGS__)
#define NOCTT_TRIANGLE(...) NOCTT_STAR(3, 0, 0, ##__VA_ARGS__)

#define NOCTT_YIELD(...) do { \
turtle->tmp = (1, ##__VA_ARGS__); \
#define NOCTT_COMMA_ ,
#define NOCTT_YIELD_(_, n_, ...) do { \
turtle->tmp = n_; \
turtle->step = NOCTT_MARKER(0, 1); \
case NOCTT_MARKER(0, 0):; \
if (turtle->tmp--) { \
turtle->iflags |= NOCTT_FLAG_DONE; \
return; \
} \
} while (0)
#define NOCTT_YIELD(...) NOCTT_YIELD_(0, ##__VA_ARGS__, 1)


#define NOCTT_CLONE(mode, ...) do { \
turtle->step = NOCTT_MARKER(0, 1); \
Expand Down Expand Up @@ -607,8 +611,10 @@ enum {
#define NOCTT_UNIQ_LABEL__(n, line) label_ ## line ## _ ## n
#define NOCTT_UNIQ_LABEL_(n, line) NOCTT_UNIQ_LABEL__(n, line)
#define NOCTT_UNIQ_LABEL(n) NOCTT_UNIQ_LABEL_(n, __LINE__)

/*
#define NOCTT_RUN_BLOCK_AND_KILL_ \
if (1) goto NOCTT_UNIQ_LABEL(0); \
if (1) {goto NOCTT_UNIQ_LABEL(0);} \
else \
while (1) \
if (1) { \
Expand All @@ -617,6 +623,15 @@ enum {
} \
else \
NOCTT_UNIQ_LABEL(0):
*/

#define NOCTT_RUN_BLOCK_AND_KILL_ \
for (turtle->iflags &= ~NOCTT_FLAG_BLOCK_DONE; ; \
turtle->iflags |= NOCTT_FLAG_BLOCK_DONE) \
if (turtle->iflags & NOCTT_FLAG_BLOCK_DONE) { \
noctt_kill(turtle); \
return; \
} else

#define NOCTT_TRANSFORM_SPAWN(...) \
NOCTT_CLONE(0, ##__VA_ARGS__); \
Expand Down
4 changes: 1 addition & 3 deletions tests/turtle.c
Expand Up @@ -347,7 +347,7 @@ static void tower(noctt_turtle_t *turtle)
// Sides
if (BRAND(0.5)) {
LOOP(n) {
SPAWN(square_up, Y, (float)turtle->i / n - 0.4, S, 1.1, 0.1);
SPAWN(square_up, Y, (float)turtle->i / n - 0.4f, S, 1.1, 0.1);
}
}

Expand Down Expand Up @@ -719,8 +719,6 @@ static void key_callback(GLFWwindow* window,

int main()
{
int i;
int r;
int w = 640, h = 480;
float proj_mat[16];

Expand Down

0 comments on commit 4322348

Please sign in to comment.