Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Handling ".c" files forcibly compiled as C++
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pbrown
Senior Member

USA
44 Posts

Posted - May 07 2017 :  10:11:52 PM  Show Profile  Reply with Quote
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

pbrown
Senior Member

USA
44 Posts

Posted - May 07 2017 :  10:26:45 PM  Show Profile  Reply with Quote
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.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18755 Posts

Posted - May 08 2017 :  06:42:19 AM  Show Profile  Reply with Quote
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.

zen is the art of being at one with the two'ness
Go to Top of Page

pbrown
Senior Member

USA
44 Posts

Posted - May 08 2017 :  2:08:02 PM  Show Profile  Reply with Quote
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>.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000