Skip to content

Conversation

@wdhongtw
Copy link

static_assert is declared in assert.h and should only be used after C11.

static_assert is declared in assert.h and should only be used after c11.
@wdhongtw
Copy link
Author

When build this tool with generate_build_files.sh and ./configure and make install,
we may see some compile failure like

gcc -DHAVE_CONFIG_H -I.    -Wall -Wshadow -fno-builtin -Wextra -Wsign-compare -Wformat=2 -Wno-format-nonliteral -Wno-unused-parameter -Wno-unused-function -std=c99 -DREGRESSION_TEST=1 -DSECONDARY_DJW=1 -DSECONDARY_FGK=1 -DXD3_MAIN=1  -DXD3_DEBUG=0 -g -O2 -MT xdelta3-xdelta3.o -MD -MP -MF .deps/xdelta3-xdelta3.Tpo -c -o xdelta3-xdelta3.o `test -f 'xdelta3.c' || echo './'`xdelta3.c
In file included from xdelta3.h:30:0,
                 from xdelta3.c:264:
config.h:65:23: error: expected declaration specifiers or ‘...’ before numeric constant
 #define SIZEOF_SIZE_T 8
                       ^
xdelta3.h:171:15: note: in expansion of macro ‘SIZEOF_SIZE_T’
 static_assert(SIZEOF_SIZE_T == sizeof(size_t), "SIZEOF_SIZE_T not correctly set");
               ^
In file included from xdelta3.c:264:0:
xdelta3.h:171:48: error: expected declaration specifiers or ‘...’ before string constant
 static_assert(SIZEOF_SIZE_T == sizeof(size_t), "SIZEOF_SIZE_T not correctly set");
                                                ^

I guess this compile do fail because compiler think that statement is a function declaration..
So compiler says that specifiers should be added.

Fix this bug by including assert.h. Also change C standard from C99 to C11, because static_assert
is added since C11.

laqieer added a commit to laqieer/FEHR that referenced this pull request Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant