<< Back to previous view

[PCC-380] cpp: EBLOCK sync error Created: 16/Sep/11  Updated: 06/Aug/12

Status: Resolved
Project: pcc
Component/s: C preprocessor
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Iain Hibbert Assignee: Anders Magnusson
Resolution: Fixed Votes: 1
Environment: NetBSD/i386

File Attachments: File mesa.c    

 Description   
The following code, reduced from MesaLib code (src/mesa/drivers/dri/r200/r200_swtcl.c)

#define warning(msg, ...) do { \
    dprint((msg), ## __VA_ARGS__); \
} while(0)

#define WARN(fmt, ...) do { \
    warning((fmt), ## __VA_ARGS__); \
} while(0)

static void foo(int d)
{
    WARN("%d\n",
        d);
}

when passed to pcc -E fails with an "EBLOCK sync error"

(the original code was more complex and runs out of macro
space but that may be a secondary issue)

 Comments   
Comment by Antoine Leca [ 13/Apr/12 05:43 PM ]
Anyway cpp does not support the (GCC extension) syntax where in
        , ## __VA_ARGS__ )
the comma is "swallowed" by the ## when __VA_ARGS__ happen to be empty

Ref: http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
Comment by Anders Magnusson [ 29/Jul/12 07:37 PM ]
This seems to have been resolved sometime during the time being.
Comment by Iain Hibbert [ 31/Jul/12 10:04 PM ]
this still occurs with pcc as of today, on i386 at least.. just to be sure (because I recall it was difficult to pin it down; I think whitespace is significant) I attach the exact code file I am using..

% pcc -E mesa.c
[....]

static void foo(int d)
{
    
mesa.c:13: error: EBLOCK sync error
% pcc --version
pcc 1.1.0.DEVEL 20120731 for netbsd-i386
Comment by Anders Magnusson [ 06/Aug/12 09:34 PM ]
Yetch, it was the newline inside the varargs arg list that was the evil spot. Thanks, fixed now.
Generated at Tue Sep 02 03:56:43 CEST 2014 using JIRA Enterprise Edition, Version: 3.13.1-#333.