Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Creator: checking syntax & highlighting



  • Hello, guys.

    I use QtCreator for editiing pure-C code. In those code I have some statements, which exist in pure-C, but exist in C++, e.g.:

    namespace is not keyword in C, but it's keyword in C++.

    At this place QtCreator check code and tells me, that I have a syntax error in this place, e.g.

    const char *namespace
    

    Does any way exist in QtCreator to set list of keywords, that must be checked by QtCreator and will be highlighted?


  • Lifetime Qt Champion

    @dimv36 Just an assumption: what are the file extensions for your C code? *.c, *.cc?



  • @jsulm I have *.c files as source code and *.h as headers.



  • I just answered on my questions myself.

    QtCreator has Keywords.cpp file located at src/libs/cplusplus/Keywords.cpp
    In those file QtCreator check given word and determine it's type (keyword as this, namespace of identifier).

    So, I comment code, which checks not-pure-C keywords, make those lib and install to qtcreator/lib/ directory. It works for me.



  • As for me, it will be great, If I can choose type of code to check (e.g. Pure-C, Pure-C++ or Qt), so, is QtCreator has any pluggable mechanism to do that?


Log in to reply