Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assertion related compile failure #241

Open
wants to merge 1 commit into
base: release3_1_apl
Choose a base branch
from

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.

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