This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS v5 Syntax Errors mixing C & C++

In my project i am getting syntax errors on lines in C files that make calls to C++ objects.  My project is configured to treat all files as C++ files when building. Is this a CCS issue or a CDT issue and how can i overcome it?  Below is an example of what i am seeing.

#include "AnalogInput.h"

void CFunction()

{

   int voltage = AnalogInput.GetPin(AnalogInput::SupplyVoltage); //Call to C++ object throws syntax error.

}

EDIT:

I made one correction. The GetPin function takes an enum of AnalogInput called using C++ syntax. If i remove the 'AnalogInput::' then the syntax error leaves but then i get a compiler warning because it doesn't know what SupplyVoltage is. And the editor highlights AnalogInput and GetPin and SupplyVoltage not declared identifiers.

  • Hi!

    If AnalogInput is your some class, then perhaps you didn't create object of this class (at least it is not clear from your code). For example:

    Analoginput   Analoginput;// The object's name better to take it different from Class name.

    But that's just a guess...

    Regards,

    Igor


  • The object does exist because i can make this same exact call in a C++ method and i don't get the syntax error.

  • Lucas Brendel said:
    In my project i am getting syntax errors on lines in C files that make calls to C++ objects.

    If I understand correctly, you are saying that the CCS editor shows syntax errors but the compiler itself does not generate any errors and the build completes fine. Is that correct? If so, it is likely a CDT parser issue and this belongs in the CCS forum (where I can move it back).

    What is the exact version of CCS you are using?

    If it is only a CDT syntax error, for the short term you could ignore the error, or you could turn off syntax error reporting in the editor by going to Window->Preferences->General->Editors->Text Editors->Annotations, select  C/C++ Indexer Markers and uncheck all the checkboxes. If you can send us a small test project that demonstrates the issue we can look into it and see if its something that can be addressed for a future release.

  • Yes, you understand correctly.

    I am using CCS 5.4. When i was using CCS 5.3 i saw the same issue.

    I did disable the index markers per your suggestion and it does get rid of the notification. The main issue i have is that the parser doesn't pick up the line for purposes such as 'Call Hierarchy', 'Rename Refactoring' and 'Syntax highlighting'.

    I can try to put something together that demonstrates my issue.

  • Hi,

    I apologize for not getting back on this, but i was able to do some more exploring today and i found the answer to my problem.

    The resolution was to change the Language Mappings for the project so that 'C Source Files' and 'C Header Files' are treated as 'TI C++ Files', since we use the Compiler option 'Treat C Files as C++ Files'. That is why we don't see any compiler issues. I probably should have mentioned that in my first post.

    Thank you

  • Sorry for the thread necro, but I ran into this also and here's what you need to do to apply Lucas's fix:

    Right-click on the project > Properties.  Click on the "show advanced settings" link at the bottom of the window.  This reveals the "C/C++ General" options.

    C/C++ General > Language Mappings > Add...

    Set 'content type' to C Source File

    Set 'language' to TI GNU C++.  

    Click Ok.  

    Click Apply.

    The indexer should re-run.

    Unfortunately, this setting does not seem to "stick" between CCS sessions and needs to be re-enabled each time.  At least, that's what I'm observing with CCS v5.5.

  • Dear all,

    I have the same issue with CCS 3.3.82.13.

    However I don't find where activate the TI GNU C++ langage to solve it.

    Some ideas ?

    With best regards,

    Sylvain.