incorrect syntax highlighting with nested ifdef
已回答
It seems like clion is not able correctly parse c files that has nested ifdef sections, especially if there is code in the inner ifdef section. For example the following file is an example of where everything within the first #ifdef is treated as includes and no syntax highlighting is available.
https://w1.fi/cgit/hostap/tree/wpa_supplicant/wpa_cli.c
Is there a setting to configure this ?
请先登录再写评论。
Hi Darshak!
Is CONFIG_CTRL_IFACE defined? If yes, please specify where and how.
>everything within the first #ifdef is treated as includes
Could you please provide a screenshot?
The CONFIG_CTRL_IFACE is defined in a defconfig file ( https://w1.fi/cgit/hostap/tree/wpa_supplicant/defconfig ) line 209.
attached below is the screenshot of how it looks in CLion
CLion doesn't see CONFIG_CTRL_IFACE as defined. As far as I see, the "hostapd and wpa_supplicant" project is not a CMake-based project originally. How have converted it into the CMake project?
I suppose if you add
to the CMakeLists.txt and reload the CMake project, CLion will be able to provide syntax highlighting for the code inside this ifdef.
Hi Anna,
Yes this isn't a CMake project. I just used the CLion "import project" and let it create the CMakeLists.txt file.
I did add the following lines explicitly in the CMakeLists.txt file but i'm still not seeing the syntax highlighting
I should have said, this isn't "originally" a CMake project.
Ok, i finally figured out how to get the syntax highlighting working. Since this is originally a Makefile project and in this particular case the Makefile's depend on a "config" file where some of the variables are defined, The CLion cmake wasn't parsing/reading variables from there.
I added an
to the CMakeLists.txt file which basically replicates the variables defined in the included config file in the Makefile and it started working.