Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Handling ".c" files forcibly compiled as C++

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
pbrown Posted - May 07 2017 : 10:11:52 PM
I work on a large code base that began its life as C code but has since upgraded to C++. During this conversion, there was not a mass rename converting all files named "File.c" to "File.cpp". Instead, the "/TP" compiler option was used to forcibly compile C files as C++.

What I'm seeing is that using my project with Visual Studio 2017 Pro and VAX version 2212. code like:

    bool value = false;
    ~~~~         ~~~~~

has underlines complaining that "bool" and "false" are unknown. I can replicate the same thing in a Visual Studio console project where I add "File.c". What I found there is if I change the project setting to enable "/TP" via

Properties->C/C++->Advanced->Compile As

the underlines go away as VAX properly recognizes the compiler option.

My problem is that my real project builds with an external tool and is configured as a "Makefile" project. There seems to be no option in Makefile projects that lets me tell Visual Assist X that I'm using "/TP".

I'm also having similar problems with ".c" files containing C++ constructors like:

    int five = int(17);


Suggestions? I suppose I could use a "stdafx.h"-based hack to deal with "bool" and related built-in types, but constructors seem more problematic.

Thanks,
Pat
3   L A T E S T    R E P L I E S    (Newest First)
pbrown Posted - May 08 2017 : 2:08:02 PM
This technique seems to be generally applicable.

Soon after posting my initial comments, I found that VAX didn't seem to be recognizing force-includes (e.g., "/FIfirst.h") in my Makefile project, either. I make a similar change to a dummy console project, pasted the relevant bits in my Makefile project, and it started working.

That one turned out to be due to the fact that my script-generated Makefile project was including the "/FI" in the project file:

    <NMakeForcedIncludes>/FIfirst.h;$(NMakeForcedIncludes)</NMakeForcedIncludes>

That presumably worked long, long ago, but isn't recognized now. However, updating the script to not tack on the "/FI" worked even without adding anything extra to <ItemDefinitionGroup>.
feline Posted - May 08 2017 : 06:42:19 AM
Thank you for the update, and I am glad you were able to find a solution, and get this working correctly for you. Also thank you for posting the solution, I don't recognise this problem, so its not a common situation, but it is still good to know how it can be fixed.
pbrown Posted - May 07 2017 : 10:26:45 PM
Never mind, soon after posting this, I decided to compare the .vcxproj file for my "real" Makefile project with the file generated in my experiment forcing "/TP" for a Visual Studio-created console project.

It turns out that if I include the setting in my Makefile project, Visual Assist now behaves as expected!

  <ItemDefinitionGroup>
    <ClCompile>
      <CompileAs>CompileAsCpp</CompileAs>
    </ClCompile>
  </ItemDefinitionGroup>


Maybe this will be useful to someone else.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000