CDT and the pre-processor

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CDT and the pre-processor

Memory, Richard

Hi All,


I am starting to look into an apparent problem with CDT's ability to follow header file include paths, header file conditionals, etc. And possibly its just my own ignorance, and I am making a mistake. Anyways, I wanted to ask the experts and make sure I am not headed in the wrong direction.


FWIW, I am using CDT 9.3 at the moment, but I am not sure the version matters here.


In my project properties, I add an include path to a directory containing the "main" header file for the sources in the project (note, in this discussion all of the include paths mentioned are external to the project). By doing so, it allows a source file in my project to successfully (ie. without error) include a header file in that directory. That said, the source file also uses pre-processor macros that are defined in a different header file.

The second header file is included by the first header file. In other words, the source file doesn't directly include the second header file, rather it only includes it indirectly because the first header file includes the second one. 

And for what it is worth, I have also added the include path to the second header file in my project properties, even though the source file doesn't directly include the second header.

The project compiles fine, but the Problems View shows errors presumably because the CDT parser isn't able to find the second header file. Possibly this happens because the CDT parser doesn't include a fully implemented pre-processor? On a related topic, I am also wondering what happens if some macros might be encapsulated by conditional pre-processor macros (which isn't the case with this particular macro, but I am wondering if this might be a problem)


Richard




_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT and the pre-processor

Jonah Graham
Hi Richard,

What you are describing sounds like an error in the scanner in
discovering all the include paths (except that you may have worked
around that by manually adding the second one). The other likely
possibility is that you have header files that change contents
depending on which file that includes them, this is affected by the
heuristic that each file is only parsed once.

I want to assure you that the CDT parser does include a fully
implemented pre-processor, just with a few heuristics to speed it up.
The standard C library has numerous cases that sound like what you are
describing and they generally work well.

Can you provide a reduced test case that demonstrates your problem?

HTH,
Jonah


~~~
Jonah Graham
Kichwa Coders Ltd.
www.kichwacoders.com


On 25 January 2018 at 16:33, Memory, Richard <[hidden email]> wrote:

> Hi All,
>
>
> I am starting to look into an apparent problem with CDT's ability to follow
> header file include paths, header file conditionals, etc. And possibly its
> just my own ignorance, and I am making a mistake. Anyways, I wanted to ask
> the experts and make sure I am not headed in the wrong direction.
>
>
> FWIW, I am using CDT 9.3 at the moment, but I am not sure the version
> matters here.
>
>
> In my project properties, I add an include path to a directory containing
> the "main" header file for the sources in the project (note, in this
> discussion all of the include paths mentioned are external to the project).
> By doing so, it allows a source file in my project to successfully (ie.
> without error) include a header file in that directory. That said, the
> source file also uses pre-processor macros that are defined in a different
> header file.
>
> The second header file is included by the first header file. In other words,
> the source file doesn't directly include the second header file, rather it
> only includes it indirectly because the first header file includes the
> second one.
>
> And for what it is worth, I have also added the include path to the second
> header file in my project properties, even though the source file doesn't
> directly include the second header.
>
> The project compiles fine, but the Problems View shows errors presumably
> because the CDT parser isn't able to find the second header file. Possibly
> this happens because the CDT parser doesn't include a fully implemented
> pre-processor? On a related topic, I am also wondering what happens if some
> macros might be encapsulated by conditional pre-processor macros (which
> isn't the case with this particular macro, but I am wondering if this might
> be a problem)
>
>
> Richard
>
>
>
>
> _______________________________________________
> cdt-dev mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev