Hello, At first,I am sorry for my poor English. I am compiling a program which processes binary data package.To avoid excess padding,it uses "#pragma" to disable padding.But an error occurred while compiling with TCC.TCC does not accept pragma option "pack" with only an operator "push".For example,
#include<stdio.h> /* This */ #pragma pack(push) #pragma pack(1) struct foo { char c; int b; }; /* This */ #pragma pack(pop) int main(void) { printf("%zd\n",sizeof(struct foo)); return 0; } Code like the above example works fine for both gcc 7.5.0 and Clang 6.0.0 on Ubuntu 18.04LTS.But tcc failed to compile it. I made a small patch to fix this problem.All tests are passed(with make test). Suote127
diff --git a/tccpp.c b/tccpp.c index 897ef15..9cba15a 100644 --- a/tccpp.c +++ b/tccpp.c @@ -1726,6 +1726,7 @@ static void pragma_parse(TCCState *s1) #pragma pack(1) // set #pragma pack() // reset to default #pragma pack(push,1) // push & set + #pragma pack(push) // push only #pragma pack(pop) // restore previous */ next(); skip('('); @@ -1744,6 +1745,8 @@ static void pragma_parse(TCCState *s1) if (s1->pack_stack_ptr >= s1->pack_stack + PACK_STACK_SIZE - 1) goto stk_error; s1->pack_stack_ptr++; + if (tok == ')') + return; skip(','); } if (tok != TOK_CINT)
_______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel