Preprocessor and parsing

Milian Wolff mail at milianw.de
Tue Apr 14 15:08:45 UTC 2015


On Friday 06 February 2015 15:42:08 Nicolás Alvarez wrote:
> 2015-02-06 14:29 GMT-03:00 Shashank Chintalagiri <shashank at chintal.in>:
> > Hi,
> > 
> > I've recently been trying to use kdevelop to build some embedded code, and
> > seem to have run into a rather trying glitch.
> > 
> > A lot of the code, both within the header files and libraries that I
> > intend
> > to use and the code that I intend to write, depends heavily on
> > preprocessor
> > directives - most importantly the -mmcu compiler flag and the directives
> > it
> > generates. In the absence of this directive, the preprocessor dumps out of
> > most of the header files because it doesn't know which processor it should
> > set up the defines for.
> > 
> > Some very old posts on the internets suggested that kdevelop 3.x did, at
> > some point, have the ability to add extra preprocessor directives to the
> > parser. Try as I might, I can't find anything like that on 4.6.0, which
> > makes using kdevelop for this disturbing.
> > 
> > So here's what I would like to know / request :
> > 
> > * Is there a way to specify custom preprocessor defines for the parser in
> > kdevelop? During the build cmake provides the necessary flags to the
> > compiler and the build works fine - I just need to be able to set some
> > relatively sane default during development to make autocomplete and
> > crossreferencing work within the editor and kdevelop.
> 
> Only way I can think of would involve editing kdevelop's code.

In master at least, you can use the custom defines/includes in the project 
settings to do anything you want. Afaik there was also work (not sure whether 
it was merged yet) to give you the ability to add compiler arguments to use 
when we get the predefined defines, i.e. your -mmcu switch.

> > * Is there any way in which kdevelop's parser announces itself to the
> > preprocessor? While not ideal (since it'll probably need to go into
> > multiple files), it should be fundamentally sufficient if I could do
> > something like :
> > 
> > #ifdef KDEVELOP_PARSER
> > #define __MSP4305529__ (or what have you)
> > #endif
> > 
> > This would allow the code to compile fine while being compatible with the
> > IDE.
> 
> The macro is called "IN_KDEVELOP_PARSER".

-- 
Milian Wolff
mail at milianw.de
http://milianw.de


More information about the KDevelop-devel mailing list