Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314495

Summary: Wrong report of a syntax error for a valid C macro
Product: [Tools] CDT Reporter: giagimari
Component: cdt-parserAssignee: Project Inbox <cdt-parser-inbox>
Status: RESOLVED WORKSFORME QA Contact: Mike Kucera <mikekucera>
Severity: normal    
Priority: P3    
Version: 7.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description giagimari CLA 2010-05-26 12:03:16 EDT
Build Identifier: I20100520-1744

A syntax error is reported for the macro container_of_var defined like this:

#define check_types_match(expr1, expr2)		\
	((typeof(expr1) *)0 != (typeof(expr2) *)0)

#define container_of(member_ptr, containing_type, member)		\
	 ((containing_type *)						\
	  ((char *)(member_ptr) - offsetof(containing_type, member))	\
	  - check_types_match(*(member_ptr), ((containing_type *)0)->member))

#define container_of_var(member_ptr, var, member) \
	container_of(member_ptr, typeof(*var), member)


Reproducible: Always

Steps to Reproduce:
An example of the use of container_of_var() to reproduce the bug could be this:

struct node {
	struct node *prev;
	struct node *next;
};

struct list {
	struct node *head;
};

struct number {
	int value;
	struct node node;
};

int main(void)
{
        struct number num;
        struct number *num_ptr;
        struct node *n = &num.node;

        num_ptr = container_of_var(n, num_ptr, node);

        return 0;
}
Comment 1 Andrew Gvozdev CLA 2010-05-26 12:11:11 EDT
Correcting the subject. Does not appear to have anything to do with error parsers (which are responsible for build output parsing).
Comment 2 giagimari CLA 2010-05-26 12:19:16 EDT
(In reply to comment #1)
> Correcting the subject. Does not appear to have anything to do with error
> parsers (which are responsible for build output parsing).
Sorry, I actually meant it like: "Parsing error", but having seen the reports with that tag I thought it was the common way to report this kind of bugs. I didn't think at all about error parsers.
Comment 3 giagimari CLA 2010-05-26 12:21:07 EDT
Notice that to make the code example compile you need to include <stddef.h>
Comment 4 Markus Schorn CLA 2010-05-27 04:22:48 EDT
The syntax error is not caused by the macro expansion, rather than that the result of the expansion cannot be parsed. To see what the parser is looking at
you can select the line with the syntax error and use 'Explore Macro Expansion' from the context menu. 

In any way your example works for me, as long as the macro 'offsetof' is defined (by including stddef.h).

In your case, most likely the include paths are not set up correctly, such that the parser cannot find the header 'stddef.h'. Another possibility is that the 
parser cannot handle the specific definition of 'offsetof' supplied by your stddef.h header.


To find out try the following:

* Replace the #include <stddef.h> with the following line, making this a self-
  contained example:
  #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
  This should make the example free of syntax errors.

* Use the definition of your stddef.h to create a self-contained example. If
  that triggers the syntax error, provide your definition of offsetof.

* Otherwise, create a parser log (Context menu of file in project explorer - 
  Index - Create Parser Log), it will tell whether the includes are found or
  not.
Comment 5 giagimari CLA 2010-05-27 07:37:34 EDT
It's true, the direct inclusion of:
#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)

cancels the syntax error report, but the include paths to <stddef.h> seem to be correct and the definition of offsetof found there is the exact same. Also I've noticed that the syntax error reported by the parser is still present in the very short example I proposed here, but it doesn't mess up the macro expansion, so it isn't even reported in the editor. Instead, in the more complex code where I first found the problem, it's reported in the editor and it messes up the macro expansion. That is, the problem is reported by the parser log in both examples, but, in the simple one, the editor doesn't report it and it doesn't mess up the rest of the parsing(and if you leave the cursor over it, it gets expanded correctly), in the more complex example it confuses the parser, so, for example, the parser cannot assist the use of -> in the pointer returned and leaving the cursor over container_of_var() doesn't present its expansion.

I'm gonna post some code examples and their relative parser logs:

###1° example

#include <stddef.h>

#define check_types_match(expr1, expr2)        \
    ((typeof(expr1) *)0 != (typeof(expr2) *)0)

#define container_of(member_ptr, containing_type, member)        \
     ((containing_type *)                        \
      ((char *)(member_ptr) - offsetof(containing_type, member))    \
      - check_types_match(*(member_ptr), ((containing_type *)0)->member))

#define container_of_var(member_ptr, var, member) \
    container_of(member_ptr, typeof(*var), member)

struct node {
    struct node *prev;
    struct node *next;
};

struct number {
    int value;
    struct node node;
};

static void test_container_of_var(void)
{
	struct number num;
	struct number *num_ptr;
	struct node *n = &num.node;

	num_ptr = container_of_var(n, num_ptr, node);
}

int main(void)
{
	test_container_of_var();
	return 0;
}

Parser log file:

Project:              eclipse_parse_test
Index Version:        6422528
Build Configuration:  Debug
File:      file:/mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/eclipse_parse_test.c
Context:   file:/mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/eclipse_parse_test.c
Language:  GNU C

Include Search Path (option -I):
   /usr/local/include
   /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include
   /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include-fixed
   /usr/include/x86_64-linux-gnu
   /usr/include

Local Include Search Path (option -iquote):

Preincluded files (option -include):

Preincluded macro files (option -imacros):

Macro definitions (option -D):
   linux=1
   unix=1
   _LP64=1
   __amd64=1
   __amd64__=1
   __BIGGEST_ALIGNMENT__=16
   __CHAR16_TYPE__=short unsigned int
   __CHAR32_TYPE__=unsigned int
   __CHAR_BIT__=8
   __DBL_DENORM_MIN__=4.9406564584124654e-324
   __DBL_DIG__=15
   __DBL_EPSILON__=2.2204460492503131e-16
   __DBL_HAS_DENORM__=1
   __DBL_HAS_INFINITY__=1
   __DBL_HAS_QUIET_NAN__=1
   __DBL_MANT_DIG__=53
   __DBL_MAX_10_EXP__=308
   __DBL_MAX_EXP__=1024
   __DBL_MAX__=1.7976931348623157e+308
   __DBL_MIN_10_EXP__=(-307)
   __DBL_MIN_EXP__=(-1021)
   __DBL_MIN__=2.2250738585072014e-308
   __DEC128_EPSILON__=1E-33DL
   __DEC128_MANT_DIG__=34
   __DEC128_MAX_EXP__=6145
   __DEC128_MAX__=9.999999999999999999999999999999999E6144DL
   __DEC128_MIN_EXP__=(-6142)
   __DEC128_MIN__=1E-6143DL
   __DEC128_SUBNORMAL_MIN__=0.000000000000000000000000000000001E-6143DL
   __DEC32_EPSILON__=1E-6DF
   __DEC32_MANT_DIG__=7
   __DEC32_MAX_EXP__=97
   __DEC32_MAX__=9.999999E96DF
   __DEC32_MIN_EXP__=(-94)
   __DEC32_MIN__=1E-95DF
   __DEC32_SUBNORMAL_MIN__=0.000001E-95DF
   __DEC64_EPSILON__=1E-15DD
   __DEC64_MANT_DIG__=16
   __DEC64_MAX_EXP__=385
   __DEC64_MAX__=9.999999999999999E384DD
   __DEC64_MIN_EXP__=(-382)
   __DEC64_MIN__=1E-383DD
   __DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD
   __DECIMAL_BID_FORMAT__=1
   __DECIMAL_DIG__=21
   __DEC_EVAL_METHOD__=2
   __ELF__=1
   __FINITE_MATH_ONLY__=0
   __FLT_DENORM_MIN__=1.40129846e-45F
   __FLT_DIG__=6
   __FLT_EPSILON__=1.19209290e-7F
   __FLT_EVAL_METHOD__=0
   __FLT_HAS_DENORM__=1
   __FLT_HAS_INFINITY__=1
   __FLT_HAS_QUIET_NAN__=1
   __FLT_MANT_DIG__=24
   __FLT_MAX_10_EXP__=38
   __FLT_MAX_EXP__=128
   __FLT_MAX__=3.40282347e+38F
   __FLT_MIN_10_EXP__=(-37)
   __FLT_MIN_EXP__=(-125)
   __FLT_MIN__=1.17549435e-38F
   __FLT_RADIX__=2
   __GCC_HAVE_DWARF2_CFI_ASM=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8=1
   __GNUC_GNU_INLINE__=1
   __GNUC_MINOR__=4
   __GNUC_PATCHLEVEL__=4
   __GNUC__=4
   __gnu_linux__=1
   __GXX_ABI_VERSION=1002
   __INTMAX_MAX__=9223372036854775807L
   __INTMAX_TYPE__=long int
   __INT_MAX__=2147483647
   __k8=1
   __k8__=1
   __LDBL_DENORM_MIN__=3.64519953188247460253e-4951L
   __LDBL_DIG__=18
   __LDBL_EPSILON__=1.08420217248550443401e-19L
   __LDBL_HAS_DENORM__=1
   __LDBL_HAS_INFINITY__=1
   __LDBL_HAS_QUIET_NAN__=1
   __LDBL_MANT_DIG__=64
   __LDBL_MAX_10_EXP__=4932
   __LDBL_MAX_EXP__=16384
   __LDBL_MAX__=1.18973149535723176502e+4932L
   __LDBL_MIN_10_EXP__=(-4931)
   __LDBL_MIN_EXP__=(-16381)
   __LDBL_MIN__=3.36210314311209350626e-4932L
   __linux=1
   __linux__=1
   __LONG_LONG_MAX__=9223372036854775807LL
   __LONG_MAX__=9223372036854775807L
   __LP64__=1
   __MMX__=1
   __NO_INLINE__=1
   __PTRDIFF_TYPE__=long int
   __REGISTER_PREFIX__=
   __SCHAR_MAX__=127
   __SHRT_MAX__=32767
   __SIZEOF_DOUBLE__=8
   __SIZEOF_FLOAT__=4
   __SIZEOF_INT__=4
   __SIZEOF_LONG_DOUBLE__=16
   __SIZEOF_LONG_LONG__=8
   __SIZEOF_LONG__=8
   __SIZEOF_POINTER__=8
   __SIZEOF_PTRDIFF_T__=8
   __SIZEOF_SHORT__=2
   __SIZEOF_SIZE_T__=8
   __SIZEOF_WCHAR_T__=4
   __SIZEOF_WINT_T__=4
   __SIZE_TYPE__=long unsigned int
   __SSE2_MATH__=1
   __SSE2__=1
   __SSE_MATH__=1
   __SSE__=1
   __STDC_HOSTED__=1
   __STDC__=1
   __UINTMAX_TYPE__=long unsigned int
   __unix=1
   __unix__=1
   __USER_LABEL_PREFIX__=
   __VERSION__="4.4.4"
   __WCHAR_MAX__=2147483647
   __WCHAR_TYPE__=int
   __WINT_TYPE__=unsigned int
   __x86_64=1
   __x86_64__=1

Macro definitions (from configuration + headers in index):
   __builtin_constant_p(exp)=0
   __builtin_offsetof(T,m)=((size_t) &((T *)0)->m)
   __builtin_types_compatible_p(x,y)=__builtin_types_compatible_p(sizeof(x),sizeof(y))
   __builtin_va_arg(ap,type)=*(typeof(type) *)ap
   __CDT_PARSER__=1
   __complex__=_Complex
   __DATE__="May 27 2010"
   __extension__=
   __FILE__="file"
   __imag__=(int)
   __LINE__=1
   __null=(void *)0
   __offsetof__(x)=(x)
   __real__=(int)
   __stdcall=
   __STDC_VERSION__=199901L
   __thread=
   __TIME__="13:15:26"

Macro definitions (from files actually parsed):
   check_types_match(expr1,expr2)=((typeof(expr1) *)0 != (typeof(expr2) *)0)
   container_of(member_ptr,containing_type,member)=((containing_type *) ((char *)(member_ptr) - offsetof(containing_type, member)) - check_types_match(*(member_ptr), ((containing_type *)0)->member))
   container_of_var(member_ptr,var,member)=container_of(member_ptr, typeof(*var), member)

Unresolved includes (from headers in index):
   file:/usr/lib/gcc/x86_64-linux-gnu/4.4/include/stddef.h is not indexed

Scanner problems:

Parser problems:
   Syntax error in file: /mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/eclipse_parse_test.c:33

Unresolved names:

Exceptions in name resolution:

###End of 1° example

###2° example

#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)

#define check_types_match(expr1, expr2)        \
    ((typeof(expr1) *)0 != (typeof(expr2) *)0)

#define container_of(member_ptr, containing_type, member)        \
     ((containing_type *)                        \
      ((char *)(member_ptr) - offsetof(containing_type, member))    \
      - check_types_match(*(member_ptr), ((containing_type *)0)->member))

#define container_of_var(member_ptr, var, member) \
    container_of(member_ptr, typeof(*var), member)

struct node {
    struct node *prev;
    struct node *next;
};

struct number {
    int value;
    struct node node;
};

static void test_container_of_var(void)
{
	struct number num;
	struct number *num_ptr;
	struct node *n = &num.node;

	num_ptr = container_of_var(n, num_ptr, node);
}

int main(void)
{
	test_container_of_var();
	return 0;
}

Parser log file:

Project:              eclipse_parse_test
Index Version:        6422528
Build Configuration:  Debug
File:      file:/mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/eclipse_parse_test.c
Context:   file:/mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/eclipse_parse_test.c
Language:  GNU C

Include Search Path (option -I):
   /usr/local/include
   /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include
   /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include-fixed
   /usr/include/x86_64-linux-gnu
   /usr/include

Local Include Search Path (option -iquote):

Preincluded files (option -include):

Preincluded macro files (option -imacros):

Macro definitions (option -D):
   linux=1
   unix=1
   _LP64=1
   __amd64=1
   __amd64__=1
   __BIGGEST_ALIGNMENT__=16
   __CHAR16_TYPE__=short unsigned int
   __CHAR32_TYPE__=unsigned int
   __CHAR_BIT__=8
   __DBL_DENORM_MIN__=4.9406564584124654e-324
   __DBL_DIG__=15
   __DBL_EPSILON__=2.2204460492503131e-16
   __DBL_HAS_DENORM__=1
   __DBL_HAS_INFINITY__=1
   __DBL_HAS_QUIET_NAN__=1
   __DBL_MANT_DIG__=53
   __DBL_MAX_10_EXP__=308
   __DBL_MAX_EXP__=1024
   __DBL_MAX__=1.7976931348623157e+308
   __DBL_MIN_10_EXP__=(-307)
   __DBL_MIN_EXP__=(-1021)
   __DBL_MIN__=2.2250738585072014e-308
   __DEC128_EPSILON__=1E-33DL
   __DEC128_MANT_DIG__=34
   __DEC128_MAX_EXP__=6145
   __DEC128_MAX__=9.999999999999999999999999999999999E6144DL
   __DEC128_MIN_EXP__=(-6142)
   __DEC128_MIN__=1E-6143DL
   __DEC128_SUBNORMAL_MIN__=0.000000000000000000000000000000001E-6143DL
   __DEC32_EPSILON__=1E-6DF
   __DEC32_MANT_DIG__=7
   __DEC32_MAX_EXP__=97
   __DEC32_MAX__=9.999999E96DF
   __DEC32_MIN_EXP__=(-94)
   __DEC32_MIN__=1E-95DF
   __DEC32_SUBNORMAL_MIN__=0.000001E-95DF
   __DEC64_EPSILON__=1E-15DD
   __DEC64_MANT_DIG__=16
   __DEC64_MAX_EXP__=385
   __DEC64_MAX__=9.999999999999999E384DD
   __DEC64_MIN_EXP__=(-382)
   __DEC64_MIN__=1E-383DD
   __DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD
   __DECIMAL_BID_FORMAT__=1
   __DECIMAL_DIG__=21
   __DEC_EVAL_METHOD__=2
   __ELF__=1
   __FINITE_MATH_ONLY__=0
   __FLT_DENORM_MIN__=1.40129846e-45F
   __FLT_DIG__=6
   __FLT_EPSILON__=1.19209290e-7F
   __FLT_EVAL_METHOD__=0
   __FLT_HAS_DENORM__=1
   __FLT_HAS_INFINITY__=1
   __FLT_HAS_QUIET_NAN__=1
   __FLT_MANT_DIG__=24
   __FLT_MAX_10_EXP__=38
   __FLT_MAX_EXP__=128
   __FLT_MAX__=3.40282347e+38F
   __FLT_MIN_10_EXP__=(-37)
   __FLT_MIN_EXP__=(-125)
   __FLT_MIN__=1.17549435e-38F
   __FLT_RADIX__=2
   __GCC_HAVE_DWARF2_CFI_ASM=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8=1
   __GNUC_GNU_INLINE__=1
   __GNUC_MINOR__=4
   __GNUC_PATCHLEVEL__=4
   __GNUC__=4
   __gnu_linux__=1
   __GXX_ABI_VERSION=1002
   __INTMAX_MAX__=9223372036854775807L
   __INTMAX_TYPE__=long int
   __INT_MAX__=2147483647
   __k8=1
   __k8__=1
   __LDBL_DENORM_MIN__=3.64519953188247460253e-4951L
   __LDBL_DIG__=18
   __LDBL_EPSILON__=1.08420217248550443401e-19L
   __LDBL_HAS_DENORM__=1
   __LDBL_HAS_INFINITY__=1
   __LDBL_HAS_QUIET_NAN__=1
   __LDBL_MANT_DIG__=64
   __LDBL_MAX_10_EXP__=4932
   __LDBL_MAX_EXP__=16384
   __LDBL_MAX__=1.18973149535723176502e+4932L
   __LDBL_MIN_10_EXP__=(-4931)
   __LDBL_MIN_EXP__=(-16381)
   __LDBL_MIN__=3.36210314311209350626e-4932L
   __linux=1
   __linux__=1
   __LONG_LONG_MAX__=9223372036854775807LL
   __LONG_MAX__=9223372036854775807L
   __LP64__=1
   __MMX__=1
   __NO_INLINE__=1
   __PTRDIFF_TYPE__=long int
   __REGISTER_PREFIX__=
   __SCHAR_MAX__=127
   __SHRT_MAX__=32767
   __SIZEOF_DOUBLE__=8
   __SIZEOF_FLOAT__=4
   __SIZEOF_INT__=4
   __SIZEOF_LONG_DOUBLE__=16
   __SIZEOF_LONG_LONG__=8
   __SIZEOF_LONG__=8
   __SIZEOF_POINTER__=8
   __SIZEOF_PTRDIFF_T__=8
   __SIZEOF_SHORT__=2
   __SIZEOF_SIZE_T__=8
   __SIZEOF_WCHAR_T__=4
   __SIZEOF_WINT_T__=4
   __SIZE_TYPE__=long unsigned int
   __SSE2_MATH__=1
   __SSE2__=1
   __SSE_MATH__=1
   __SSE__=1
   __STDC_HOSTED__=1
   __STDC__=1
   __UINTMAX_TYPE__=long unsigned int
   __unix=1
   __unix__=1
   __USER_LABEL_PREFIX__=
   __VERSION__="4.4.4"
   __WCHAR_MAX__=2147483647
   __WCHAR_TYPE__=int
   __WINT_TYPE__=unsigned int
   __x86_64=1
   __x86_64__=1

Macro definitions (from configuration + headers in index):
   __builtin_constant_p(exp)=0
   __builtin_offsetof(T,m)=((size_t) &((T *)0)->m)
   __builtin_types_compatible_p(x,y)=__builtin_types_compatible_p(sizeof(x),sizeof(y))
   __builtin_va_arg(ap,type)=*(typeof(type) *)ap
   __CDT_PARSER__=1
   __complex__=_Complex
   __DATE__="May 27 2010"
   __extension__=
   __FILE__="file"
   __imag__=(int)
   __LINE__=1
   __null=(void *)0
   __offsetof__(x)=(x)
   __real__=(int)
   __stdcall=
   __STDC_VERSION__=199901L
   __thread=
   __TIME__="13:19:41"

Macro definitions (from files actually parsed):
   check_types_match(expr1,expr2)=((typeof(expr1) *)0 != (typeof(expr2) *)0)
   container_of(member_ptr,containing_type,member)=((containing_type *) ((char *)(member_ptr) - offsetof(containing_type, member)) - check_types_match(*(member_ptr), ((containing_type *)0)->member))
   container_of_var(member_ptr,var,member)=container_of(member_ptr, typeof(*var), member)
   offsetof(TYPE,MEMBER)=__builtin_offsetof(TYPE, MEMBER)

Unresolved includes (from headers in index):

Scanner problems:

Parser problems:

Unresolved names:
   Attempt to use symbol failed: size_t in file /mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/eclipse_parse_test.c:33

Exceptions in name resolution:


Here the error is gone, as expected(anyway, why does it try to use size_t there?(33 is the line where it's used container_of_var)).

###End of 2° example


###3° example

If I put those definitions and the include of stddef.h in a header, there's no syntax error(In this example. In more complex code I talked about above, those definitions are in a header, but there's still a syntax error).

file parse_test.h:

#ifndef PARSE_TEST_H_
#define PARSE_TEST_H_

#include <stddef.h>

#define check_types_match(expr1, expr2)        \
    ((typeof(expr1) *)0 != (typeof(expr2) *)0)

#define container_of(member_ptr, containing_type, member)        \
     ((containing_type *)                        \
      ((char *)(member_ptr) - offsetof(containing_type, member))    \
      - check_types_match(*(member_ptr), ((containing_type *)0)->member))

#define container_of_var(member_ptr, var, member) \
    container_of(member_ptr, typeof(*var), member)

struct node {
    struct node *prev;
    struct node *next;
};

#endif /* PARSE_TEST_H_ */

file eclipse_parse_test.c:

#include "parse_test.h"

struct number {
    int value;
    struct node node;
};

static void test_container_of_var(void)
{
	struct number num;
	struct number *num_ptr;
	struct node *n = &num.node;

	num_ptr = container_of_var(n, num_ptr, node);
}

int main(void)
{
	test_container_of_var();
	return 0;
}

Parser log file of parse_test.h:

Project:              eclipse_parse_test
Index Version:        6422528
Build Configuration:  Debug
File:      file:/mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/parse_test.h
Context:   file:/mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/parse_test.h
Language:  GNU C

Include Search Path (option -I):
   /usr/local/include
   /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include
   /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include-fixed
   /usr/include/x86_64-linux-gnu
   /usr/include

Local Include Search Path (option -iquote):

Preincluded files (option -include):

Preincluded macro files (option -imacros):

Macro definitions (option -D):
   linux=1
   unix=1
   _LP64=1
   __amd64=1
   __amd64__=1
   __BIGGEST_ALIGNMENT__=16
   __CHAR16_TYPE__=short unsigned int
   __CHAR32_TYPE__=unsigned int
   __CHAR_BIT__=8
   __DBL_DENORM_MIN__=4.9406564584124654e-324
   __DBL_DIG__=15
   __DBL_EPSILON__=2.2204460492503131e-16
   __DBL_HAS_DENORM__=1
   __DBL_HAS_INFINITY__=1
   __DBL_HAS_QUIET_NAN__=1
   __DBL_MANT_DIG__=53
   __DBL_MAX_10_EXP__=308
   __DBL_MAX_EXP__=1024
   __DBL_MAX__=1.7976931348623157e+308
   __DBL_MIN_10_EXP__=(-307)
   __DBL_MIN_EXP__=(-1021)
   __DBL_MIN__=2.2250738585072014e-308
   __DEC128_EPSILON__=1E-33DL
   __DEC128_MANT_DIG__=34
   __DEC128_MAX_EXP__=6145
   __DEC128_MAX__=9.999999999999999999999999999999999E6144DL
   __DEC128_MIN_EXP__=(-6142)
   __DEC128_MIN__=1E-6143DL
   __DEC128_SUBNORMAL_MIN__=0.000000000000000000000000000000001E-6143DL
   __DEC32_EPSILON__=1E-6DF
   __DEC32_MANT_DIG__=7
   __DEC32_MAX_EXP__=97
   __DEC32_MAX__=9.999999E96DF
   __DEC32_MIN_EXP__=(-94)
   __DEC32_MIN__=1E-95DF
   __DEC32_SUBNORMAL_MIN__=0.000001E-95DF
   __DEC64_EPSILON__=1E-15DD
   __DEC64_MANT_DIG__=16
   __DEC64_MAX_EXP__=385
   __DEC64_MAX__=9.999999999999999E384DD
   __DEC64_MIN_EXP__=(-382)
   __DEC64_MIN__=1E-383DD
   __DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD
   __DECIMAL_BID_FORMAT__=1
   __DECIMAL_DIG__=21
   __DEC_EVAL_METHOD__=2
   __ELF__=1
   __FINITE_MATH_ONLY__=0
   __FLT_DENORM_MIN__=1.40129846e-45F
   __FLT_DIG__=6
   __FLT_EPSILON__=1.19209290e-7F
   __FLT_EVAL_METHOD__=0
   __FLT_HAS_DENORM__=1
   __FLT_HAS_INFINITY__=1
   __FLT_HAS_QUIET_NAN__=1
   __FLT_MANT_DIG__=24
   __FLT_MAX_10_EXP__=38
   __FLT_MAX_EXP__=128
   __FLT_MAX__=3.40282347e+38F
   __FLT_MIN_10_EXP__=(-37)
   __FLT_MIN_EXP__=(-125)
   __FLT_MIN__=1.17549435e-38F
   __FLT_RADIX__=2
   __GCC_HAVE_DWARF2_CFI_ASM=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8=1
   __GNUC_GNU_INLINE__=1
   __GNUC_MINOR__=4
   __GNUC_PATCHLEVEL__=4
   __GNUC__=4
   __gnu_linux__=1
   __GXX_ABI_VERSION=1002
   __INTMAX_MAX__=9223372036854775807L
   __INTMAX_TYPE__=long int
   __INT_MAX__=2147483647
   __k8=1
   __k8__=1
   __LDBL_DENORM_MIN__=3.64519953188247460253e-4951L
   __LDBL_DIG__=18
   __LDBL_EPSILON__=1.08420217248550443401e-19L
   __LDBL_HAS_DENORM__=1
   __LDBL_HAS_INFINITY__=1
   __LDBL_HAS_QUIET_NAN__=1
   __LDBL_MANT_DIG__=64
   __LDBL_MAX_10_EXP__=4932
   __LDBL_MAX_EXP__=16384
   __LDBL_MAX__=1.18973149535723176502e+4932L
   __LDBL_MIN_10_EXP__=(-4931)
   __LDBL_MIN_EXP__=(-16381)
   __LDBL_MIN__=3.36210314311209350626e-4932L
   __linux=1
   __linux__=1
   __LONG_LONG_MAX__=9223372036854775807LL
   __LONG_MAX__=9223372036854775807L
   __LP64__=1
   __MMX__=1
   __NO_INLINE__=1
   __PTRDIFF_TYPE__=long int
   __REGISTER_PREFIX__=
   __SCHAR_MAX__=127
   __SHRT_MAX__=32767
   __SIZEOF_DOUBLE__=8
   __SIZEOF_FLOAT__=4
   __SIZEOF_INT__=4
   __SIZEOF_LONG_DOUBLE__=16
   __SIZEOF_LONG_LONG__=8
   __SIZEOF_LONG__=8
   __SIZEOF_POINTER__=8
   __SIZEOF_PTRDIFF_T__=8
   __SIZEOF_SHORT__=2
   __SIZEOF_SIZE_T__=8
   __SIZEOF_WCHAR_T__=4
   __SIZEOF_WINT_T__=4
   __SIZE_TYPE__=long unsigned int
   __SSE2_MATH__=1
   __SSE2__=1
   __SSE_MATH__=1
   __SSE__=1
   __STDC_HOSTED__=1
   __STDC__=1
   __UINTMAX_TYPE__=long unsigned int
   __unix=1
   __unix__=1
   __USER_LABEL_PREFIX__=
   __VERSION__="4.4.4"
   __WCHAR_MAX__=2147483647
   __WCHAR_TYPE__=int
   __WINT_TYPE__=unsigned int
   __x86_64=1
   __x86_64__=1

Macro definitions (from configuration + headers in index):
   __builtin_constant_p(exp)=0
   __builtin_offsetof(T,m)=((size_t) &((T *)0)->m)
   __builtin_types_compatible_p(x,y)=__builtin_types_compatible_p(sizeof(x),sizeof(y))
   __builtin_va_arg(ap,type)=*(typeof(type) *)ap
   __CDT_PARSER__=1
   __complex__=_Complex
   __DATE__="May 27 2010"
   __extension__=
   __FILE__="file"
   __imag__=(int)
   __LINE__=1
   __null=(void *)0
   __offsetof__(x)=(x)
   __real__=(int)
   __stdcall=
   __STDC_VERSION__=199901L
   __thread=
   __TIME__="13:31:54"

Macro definitions (from files actually parsed):
   check_types_match(expr1,expr2)=((typeof(expr1) *)0 != (typeof(expr2) *)0)
   container_of(member_ptr,containing_type,member)=((containing_type *) ((char *)(member_ptr) - offsetof(containing_type, member)) - check_types_match(*(member_ptr), ((containing_type *)0)->member))
   container_of_var(member_ptr,var,member)=container_of(member_ptr, typeof(*var), member)
   PARSE_TEST_H_=

Unresolved includes (from headers in index):
   file:/usr/lib/gcc/x86_64-linux-gnu/4.4/include/stddef.h is not indexed

Scanner problems:

Parser problems:

Unresolved names:

Exceptions in name resolution:



Parser log file of eclipse_parse_test.c:

Project:              eclipse_parse_test
Index Version:        6422528
Build Configuration:  Debug
File:      file:/mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/eclipse_parse_test.c
Context:   file:/mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/eclipse_parse_test.c
Language:  GNU C

Include Search Path (option -I):
   /usr/local/include
   /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include
   /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include-fixed
   /usr/include/x86_64-linux-gnu
   /usr/include

Local Include Search Path (option -iquote):

Preincluded files (option -include):

Preincluded macro files (option -imacros):

Macro definitions (option -D):
   linux=1
   unix=1
   _LP64=1
   __amd64=1
   __amd64__=1
   __BIGGEST_ALIGNMENT__=16
   __CHAR16_TYPE__=short unsigned int
   __CHAR32_TYPE__=unsigned int
   __CHAR_BIT__=8
   __DBL_DENORM_MIN__=4.9406564584124654e-324
   __DBL_DIG__=15
   __DBL_EPSILON__=2.2204460492503131e-16
   __DBL_HAS_DENORM__=1
   __DBL_HAS_INFINITY__=1
   __DBL_HAS_QUIET_NAN__=1
   __DBL_MANT_DIG__=53
   __DBL_MAX_10_EXP__=308
   __DBL_MAX_EXP__=1024
   __DBL_MAX__=1.7976931348623157e+308
   __DBL_MIN_10_EXP__=(-307)
   __DBL_MIN_EXP__=(-1021)
   __DBL_MIN__=2.2250738585072014e-308
   __DEC128_EPSILON__=1E-33DL
   __DEC128_MANT_DIG__=34
   __DEC128_MAX_EXP__=6145
   __DEC128_MAX__=9.999999999999999999999999999999999E6144DL
   __DEC128_MIN_EXP__=(-6142)
   __DEC128_MIN__=1E-6143DL
   __DEC128_SUBNORMAL_MIN__=0.000000000000000000000000000000001E-6143DL
   __DEC32_EPSILON__=1E-6DF
   __DEC32_MANT_DIG__=7
   __DEC32_MAX_EXP__=97
   __DEC32_MAX__=9.999999E96DF
   __DEC32_MIN_EXP__=(-94)
   __DEC32_MIN__=1E-95DF
   __DEC32_SUBNORMAL_MIN__=0.000001E-95DF
   __DEC64_EPSILON__=1E-15DD
   __DEC64_MANT_DIG__=16
   __DEC64_MAX_EXP__=385
   __DEC64_MAX__=9.999999999999999E384DD
   __DEC64_MIN_EXP__=(-382)
   __DEC64_MIN__=1E-383DD
   __DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD
   __DECIMAL_BID_FORMAT__=1
   __DECIMAL_DIG__=21
   __DEC_EVAL_METHOD__=2
   __ELF__=1
   __FINITE_MATH_ONLY__=0
   __FLT_DENORM_MIN__=1.40129846e-45F
   __FLT_DIG__=6
   __FLT_EPSILON__=1.19209290e-7F
   __FLT_EVAL_METHOD__=0
   __FLT_HAS_DENORM__=1
   __FLT_HAS_INFINITY__=1
   __FLT_HAS_QUIET_NAN__=1
   __FLT_MANT_DIG__=24
   __FLT_MAX_10_EXP__=38
   __FLT_MAX_EXP__=128
   __FLT_MAX__=3.40282347e+38F
   __FLT_MIN_10_EXP__=(-37)
   __FLT_MIN_EXP__=(-125)
   __FLT_MIN__=1.17549435e-38F
   __FLT_RADIX__=2
   __GCC_HAVE_DWARF2_CFI_ASM=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4=1
   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8=1
   __GNUC_GNU_INLINE__=1
   __GNUC_MINOR__=4
   __GNUC_PATCHLEVEL__=4
   __GNUC__=4
   __gnu_linux__=1
   __GXX_ABI_VERSION=1002
   __INTMAX_MAX__=9223372036854775807L
   __INTMAX_TYPE__=long int
   __INT_MAX__=2147483647
   __k8=1
   __k8__=1
   __LDBL_DENORM_MIN__=3.64519953188247460253e-4951L
   __LDBL_DIG__=18
   __LDBL_EPSILON__=1.08420217248550443401e-19L
   __LDBL_HAS_DENORM__=1
   __LDBL_HAS_INFINITY__=1
   __LDBL_HAS_QUIET_NAN__=1
   __LDBL_MANT_DIG__=64
   __LDBL_MAX_10_EXP__=4932
   __LDBL_MAX_EXP__=16384
   __LDBL_MAX__=1.18973149535723176502e+4932L
   __LDBL_MIN_10_EXP__=(-4931)
   __LDBL_MIN_EXP__=(-16381)
   __LDBL_MIN__=3.36210314311209350626e-4932L
   __linux=1
   __linux__=1
   __LONG_LONG_MAX__=9223372036854775807LL
   __LONG_MAX__=9223372036854775807L
   __LP64__=1
   __MMX__=1
   __NO_INLINE__=1
   __PTRDIFF_TYPE__=long int
   __REGISTER_PREFIX__=
   __SCHAR_MAX__=127
   __SHRT_MAX__=32767
   __SIZEOF_DOUBLE__=8
   __SIZEOF_FLOAT__=4
   __SIZEOF_INT__=4
   __SIZEOF_LONG_DOUBLE__=16
   __SIZEOF_LONG_LONG__=8
   __SIZEOF_LONG__=8
   __SIZEOF_POINTER__=8
   __SIZEOF_PTRDIFF_T__=8
   __SIZEOF_SHORT__=2
   __SIZEOF_SIZE_T__=8
   __SIZEOF_WCHAR_T__=4
   __SIZEOF_WINT_T__=4
   __SIZE_TYPE__=long unsigned int
   __SSE2_MATH__=1
   __SSE2__=1
   __SSE_MATH__=1
   __SSE__=1
   __STDC_HOSTED__=1
   __STDC__=1
   __UINTMAX_TYPE__=long unsigned int
   __unix=1
   __unix__=1
   __USER_LABEL_PREFIX__=
   __VERSION__="4.4.4"
   __WCHAR_MAX__=2147483647
   __WCHAR_TYPE__=int
   __WINT_TYPE__=unsigned int
   __x86_64=1
   __x86_64__=1

Macro definitions (from configuration + headers in index):
   __builtin_constant_p(exp)=0
   __builtin_offsetof(T,m)=((size_t) &((T *)0)->m)
   __builtin_types_compatible_p(x,y)=__builtin_types_compatible_p(sizeof(x),sizeof(y))
   __builtin_va_arg(ap,type)=*(typeof(type) *)ap
   __CDT_PARSER__=1
   __complex__=_Complex
   __DATE__="May 27 2010"
   __extension__=
   __FILE__="file"
   __imag__=(int)
   __LINE__=1
   __null=(void *)0
   __offsetof__(x)=(x)
   __real__=(int)
   __stdcall=
   __STDC_VERSION__=199901L
   __thread=
   __TIME__="13:31:28"

Macro definitions (from files actually parsed):

Unresolved includes (from headers in index):
   file:/mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/parse_test.h is not indexed

Scanner problems:

Parser problems:

Unresolved names:
   Attempt to use symbol failed: node in file /mnt/disk-3/eclipse_workspace/eclipse_parse_test/src/eclipse_parse_test.c:33

Exceptions in name resolution:


###End of 3° example
Comment 6 Markus Schorn CLA 2010-05-27 08:15:21 EDT
The logs suggest that the project is not indexed. In the project properties on the indexer page select 'Enable indexer' and to be sure also select 'Index source files not included in the build'. This should fix your problem.
Comment 7 giagimari CLA 2010-05-27 10:41:50 EDT
(In reply to comment #6)
> The logs suggest that the project is not indexed. In the project properties on
> the indexer page select 'Enable indexer' and to be sure also select 'Index
> source files not included in the build'. This should fix your problem.
I didn't set anything project specific about the indexer though and the general indexing settings are:

-Enable Indexer
    -Index source files not included in the build
    -Index unused headers
    -Allow heuristic resolution of includes
    -Skip files larger than 8Mb
    -Files to index up-front:
        stdarg.h, stddef.h, sys/types.h

Do I have to set project specific indexing options each time? If so, then what's the point of the general options?
Comment 8 giagimari CLA 2010-05-27 10:59:01 EDT
(In reply to comment #7)
> Do I have to set project specific indexing options each time? If so, then
> what's the point of the general options?
And, by the way, project specific or not doesn't change much. The indexing options are already set, they just don't seem to work.
Comment 9 Markus Schorn CLA 2010-05-28 07:16:28 EDT
Please check whether the file eclipse_parse_test.c is part of the index. (Context menu of editor - Show In - Include Browser). Does it open the Include Browser, what does it show.

Also please reindex the project (Context menu of project - Index - Rebuild). After the indexer completes it writes a short summary in the error log. Does it output the summary what does it write? (<your_workspace>/.metadata/.log)

Does the log contain any other suspicious entries?
Comment 10 giagimari CLA 2010-05-28 07:55:58 EDT
(In reply to comment #9)
> Please check whether the file eclipse_parse_test.c is part of the index.
> (Context menu of editor - Show In - Include Browser). Does it open the Include
> Browser, what does it show.
> 
> Also please reindex the project (Context menu of project - Index - Rebuild).
> After the indexer completes it writes a short summary in the error log. Does it
> output the summary what does it write? (<your_workspace>/.metadata/.log)
> 
> Does the log contain any other suspicious entries?

I tried this for every project I was having problems with and none of the source files showed up in the include browser. Then I rebuilt the index of every project as you told me and this time the indexes were really built, so no syntax errors were reported anymore. Why did this happen though? My general index settings have always been like that and I never set anything project specific for the index. Also, the fact that a rebuild of the index works means that the settings are right, it's just that the index doesn't get built(unless I do a "rebuild it"), right?

Anyway, this is the relevant part of the log you asked for:
!ENTRY org.eclipse.cdt.core 1 0 2010-05-28 13:44:53.925
!MESSAGE Indexed 'eclipse_parse_test' (1 sources, 22 headers) in 0.06 sec: 267 declarations; 510 references; 0 unresolved inclusions; 0 syntax errors; 0 unresolved names (0.00%)
Comment 11 Markus Schorn CLA 2010-05-28 09:01:04 EDT
Hmm, please double check the indexer preference page whether the option 'automatically update the index' is selected (Window - Preferences - C/C++ - Indexer). If it is the index is the index is kept up to date automatically.
Comment 12 Markus Schorn CLA 2010-05-28 09:02:14 EDT
(In reply to comment #11)
> If it is the index is the index is kept up to date automatically.
Great English: If it is selected, then the index is kept up to date automatically.
Comment 13 giagimari CLA 2010-05-28 09:22:19 EDT
(In reply to comment #12)
> (In reply to comment #11)
> > If it is the index is the index is kept up to date automatically.
> Great English: If it is selected, then the index is kept up to date
> automatically.
Yes, both 'Automatically update the index' and 'Update index immediately after every file-save' are selected.
Comment 14 Markus Schorn CLA 2010-05-28 10:06:13 EDT
When you add a new header file to eclipse_parse_test.c and save the file, is the index updated? (Check by opening the include browser, does it show the additional include?)
Comment 15 giagimari CLA 2010-05-28 10:07:17 EDT
After having rebuilt the index for those projects, I noticed that I can't reproduce the bug anymore on newer projects. All this without changing any of my settings.
Comment 16 giagimari CLA 2010-05-28 10:17:28 EDT
(In reply to comment #14)
> When you add a new header file to eclipse_parse_test.c and save the file, is
> the index updated? (Check by opening the include browser, does it show the
> additional include?)
Yes, it does. But notice also my previous post:
After having rebuilt the index for those projects, I noticed that I can't
reproduce the bug anymore on newer projects. All this without changing any of
my settings.

I don't know, after having rebuilt those indices, now everything seems to work in new unrelated projects.
Comment 17 Markus Schorn CLA 2010-05-31 05:47:42 EDT
(In reply to comment #16)
> (In reply to comment #14)
> > When you add a new header file to eclipse_parse_test.c and save the file, is
> > the index updated? (Check by opening the include browser, does it show the
> > additional include?)
> Yes, it does. But notice also my previous post:
> After having rebuilt the index for those projects, I noticed that I can't
> reproduce the bug anymore on newer projects. All this without changing any of
> my settings.
> 
> I don't know, after having rebuilt those indices, now everything seems to work
> in new unrelated projects.

Ok, looks like your index(es) got out of sync with the file-system. After fixing that by rebuilding the index things seem to work fine. There are multiple possibilities on how to get the index out of sync including:
* manual cancellation of the indexer job.
* changing configuration (source roots, filters, include paths, etc.)
* changing workspace external files (found via inclusions).
In these cases you need to rebuild the index.
Comment 18 giagimari CLA 2010-05-31 14:28:58 EDT
(In reply to comment #17)
> (In reply to comment #16)
> > (In reply to comment #14)
> > > When you add a new header file to eclipse_parse_test.c and save the file, is
> > > the index updated? (Check by opening the include browser, does it show the
> > > additional include?)
> > Yes, it does. But notice also my previous post:
> > After having rebuilt the index for those projects, I noticed that I can't
> > reproduce the bug anymore on newer projects. All this without changing any of
> > my settings.
> > 
> > I don't know, after having rebuilt those indices, now everything seems to work
> > in new unrelated projects.
> 
> Ok, looks like your index(es) got out of sync with the file-system. After
> fixing that by rebuilding the index things seem to work fine. There are
> multiple possibilities on how to get the index out of sync including:
> * manual cancellation of the indexer job.
> * changing configuration (source roots, filters, include paths, etc.)
> * changing workspace external files (found via inclusions).
> In these cases you need to rebuild the index.
Ok. I don't want to add noise by posting a useless comment, but I wanted to thank you for your help with this problem, so thank you.