C/C++ How to handle the Specification and Implementation files to be used in C++?

  • Thread starter Thread starter yungman
  • Start date Start date
  • Tags Tags
    files
Click For Summary
The discussion revolves around the challenges of organizing and integrating C++ class files, specifically the header (.h) and implementation (.cpp) files, while using Visual Studio. The user expresses frustration over needing to use absolute paths for includes, which complicates file management. Suggestions include keeping all project files in a single folder to simplify includes, as well as utilizing Visual Studio's project properties to set additional include directories. The conversation highlights the importance of modular code organization, with a focus on separating class declarations and definitions for better management. There are also discussions about the potential for confusion when compiling separate files and the benefits of learning to manage project structures effectively. The user ultimately finds a method that works for them, though they acknowledge the learning curve and inconsistencies in Visual Studio. They also reflect on the broader concepts of object-oriented programming and the importance of understanding class structures as they progress in their studies.
  • #61
I printed out the response, I need to take time to read it. I'll be back.

thanks
 
Technology news on Phys.org
  • #62
Mark44 said:
For a project named Temp, VS keeps track of where all the files are in a file named Temp.vcxproj. This is a text file, so you can read it. It's not a good idea for you to edit it, if you don't know what you're doing. You can find the .vcxproj file for your project in the 2nd-level directory for your project, which will normally have the same name as the top-level directory.
.....
Do you mean Temp.vcxproj.filter? I use notepad to open this file and these are the 3,

First one is with all 3 files physically in the project. You can see all three at the bottom.
vcxproj.filter with files in project.jpg

This one with Add-->Existence. You can see it shows the path to the files
vcxproj.filter without files in project.jpg

Finally the one with only the source.cpp physically in the project folder
vcxproj.filter one files in project.jpg

Is this what you are referring to, that I should check this to know where the files are? regarding to you said you don't have enough info to comment on the Temp project that doesn't work with mixed Add-->New and Add-->Existing. The 3rd print out is the file. You can see where the 3 files came from, see whether you can make some heads and tails out of it.

I am still reading through the responses.

Thanks
 
  • #63
Screenshot (50).png

Screenshot (51).png
 
  • Like
Likes yungman
  • #64
Jarvis323 said:
Hi Jarvis

Thanks for still helping me, I really appreciate this. I follow you and get to this point but I really don't follow what am I supposed to do with it next.

Jarvis323 said:
After a search, I found that the "additional include directories" option is in the C++ General tab for VS 2019.
https://docs.microsoft.com/en-us/cpp/linux/prop-pages/general-linux?view=vs-2019

I really don't follow what's going on here. what do you want me to learn from this? I am really lost.

Thanks
 
  • #65
yungman said:
Do you mean Temp.vcxproj.filter?
No, I mean just exactly what I said -- <project_name>.vcxproj. In this case, it would be Temp.vcxproj.
 
  • #66
Hi Guys

I really don't follow what's going on here. I thought in Solution Explorer, there is Header files that I add in the .h files and Source files that I add in the .cpp files. Maybe at this time, I should just accept that I can only do Add-->New to either the Header files and Source files in the Solution explorer, then I can move on. Any other things I need to watch out?

Thanks everyone for the time.
 
  • #67
  • #68
Mark44 said:
No, I mean just exactly what I said -- <project_name>.vcxproj. In this case, it would be Temp.vcxproj.
I tried that, this is what I got:
Nothing like you described.

Thanks
 

Attachments

  • #69
yungman said:
Hi Jarvis

Thanks for still helping me, I really appreciate this. I follow you and get to this point but I really don't follow what am I supposed to do with it next.
I really don't follow what's going on here. what do you want me to learn from this? I am really lost.

Thanks
You just add the path of your header files in that box that I pointed out. Then when the compiler compiles your program, it will look for header files in those directories that you've listed in the box. That is the solution to your problem. Then you won't get the error that the header file wasn't found, and no matter how you added the files to the project, it will work. I went over what is going on multiple times already in previous posts, but I guess there is a communication barrier we can't get through.

I recommend to just keep it as simple as possible and follow Mark's advice on how to get something working. If you want to figure out how to put files somewhere else besides the project directory, or figure out what was wrong with what you've done, you can always come back to and re-read the thread.
 
  • Like
Likes yungman
  • #70
Jarvis323 said:
You just add the path of your header files in that box that I pointed out. Then when the compiler compiles your program, it will look for header files in those directories that you've listed in the box. That is the solution to your problem. Then you won't get the error that the header file wasn't found, and no matter how you added the files to the project, it will work. I went over what is going on multiple times already in previous posts, but I guess there is a communication barrier we can't get through.

I recommend to just keep it as simple as possible and follow Mark's advice on how to get something working. If you want to figure out how to put files somewhere else besides the project directory, or figure out what was wrong with what you've done, you can always come back to and re-read the thread.
You mean like this:
Add directory.jpg


I added it in and hit apply. I went back to Solution Explorer, I did not see that. There is no indication I added anything.

yes, I feel I am wasting you and Mark's time. I just stick with using Add-->New and copy or type in the codes and it will work for now. Again, thanks for taking the time to help me.

Thanks
 
  • #71
If you have spaces in the path then you need to put quotes around it I think "c:\...". You can use the browser to select the folder if you hit the down arrow, and then the file icon.

Nothing will be indicated and no files will be added to the project. But the red squiggly under your #include "someheaderfileinrandomfolder.h" will go away and your problem that the compiler didn't know where to look for your header files will be solved and your program will compile fine.

IMPORTANT: also, the configuration selected in the upper left corner needs to be set to "All Configurations" if you want it to apply to both "Debug" and "Release" modes.
 
Last edited:
  • Like
Likes yungman
  • #72
Jarvis323 said:
If you have spaces it might be a problem. You can use the browser to select the folder if you hit the down arrow, and then the file icon.

Nothing will be indicated and no files will be added to the project. But the red squiggly under your include will go away and your program will compile fine.
I think I got it:

I click Edit, this is the menu that show up:
Edit manual.jpg


Then I hit the file icon and search the path and OK.
Add directory.jpg


But I still don't see anything added in the Solution Explorer. Looks the same as before I added it.

Thanks
 
  • #73
yungman said:
I think I got it:

I click Edit, this is the menu that show up:
View attachment 270501

Then I hit the file icon and search the path and OK.
View attachment 270502

But I still don't see anything added in the Solution Explorer. Looks the same as before I added it.

Thanks
It shouldn't look any different. But now your project will compile successfully. Also if you open the vcxproj file in notepad you will see a line that it generated.
 
  • Like
Likes yungman
  • #74
yungman said:
I tried that, this is what I got:
Nothing like you described.

Thanks
Is this from a project that doesn't build?
This is what Temp.vcxproj looks like for my working program. Down toward the bottom is where the source files and header files are listed.
XML:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <VCProjectVersion>15.0</VCProjectVersion>
    <ProjectGuid>{65181934-D7D5-42C1-9FA7-E8A4CB3EF064}</ProjectGuid>
    <Keyword>Win32Proj</Keyword>
    <RootNamespace>Temp</RootNamespace>
    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v141</PlatformToolset>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v141</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v141</PlatformToolset>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v141</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="Shared">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <LinkIncremental>true</LinkIncremental>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <LinkIncremental>true</LinkIncremental>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <LinkIncremental>false</LinkIncremental>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <LinkIncremental>false</LinkIncremental>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClInclude Include="Rectangle.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="Rectangle.cpp" />
    <ClCompile Include="RectImpl.cpp" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
 
  • #75
Jarvis323 said:
It shouldn't look any different. But now your project will compile successfully. Also if you open the vcxproj file in notepad you will see a line that it generated.
THANKS A MILLION

How do you know that! You said you don't even use VS!

Yes, that works. I did it on the Temp file and I runs!

Ha ha, I mess up something, some how, I closed the Solution Explorer and I can't get back my normal stuffs on the right. But that's a different problem I created myself.

I can sleep better now.

Thanks I really appreciate your help. This resolve my very problem. Now I know I have to go to include external files.
 
  • #76
Mark44 said:
Is this from a project that doesn't build?
This is what Temp.vcxproj looks like for my working program. Down toward the bottom is where the source files and header files are listed.
XML:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <VCProjectVersion>15.0</VCProjectVersion>
    <ProjectGuid>{65181934-D7D5-42C1-9FA7-E8A4CB3EF064}</ProjectGuid>
    <Keyword>Win32Proj</Keyword>
    <RootNamespace>Temp</RootNamespace>
    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v141</PlatformToolset>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v141</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v141</PlatformToolset>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v141</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="Shared">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <LinkIncremental>true</LinkIncremental>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <LinkIncremental>true</LinkIncremental>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <LinkIncremental>false</LinkIncremental>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <LinkIncremental>false</LinkIncremental>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClInclude Include="Rectangle.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="Rectangle.cpp" />
    <ClCompile Include="RectImpl.cpp" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
It is not like this, there only very little stuffs in it. I linked the txt file in post#68. It looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
</Project>
Anyway, I had itchy fingers, somehow I closed the Solution explorer, how can I open it back. VS has memory, I screwed up in one file, I closed it. I open another project, my screw up pass on to the next project! Now I don't have Solution Explorer in other projects. Is there a quick way to go back to default? I am having a hard time with VS, more so than C++!

Thanks
 
  • #77
yungman said:
It is not like this, there only very little stuffs in it. I linked the txt file in post#68. It looks like this:
Yes, I saw the file you had attached. If that was the whole thing, then it's no wonder the program wouldn't build. Best thing to do is to save the three files (the two .cpp files and the header file) somewhere, close VS, and from Windows Explorer, delete the directories.
Then start from scratch with a new project. If you have deleted the Temp directory and everything under it (after saving the three files I mentioned), you can
create a new empty project (you can call it Temp or whatever),
In VS, Add --> New items in the Source Files directory.
In VS, Add --> New items in the Include Files directory.
Copy each of the saved files into the source file and header file place-holders
Build.
yungman said:
Anyway, I had itchy fingers, somehow I closed the Solution explorer, how can I open it back.
View menu --> Solution Explorer
 
  • Like
Likes yungman
  • #78
Mark44 said:
Yes, I saw the file you had attached. If that was the whole thing, then it's no wonder the program wouldn't build. Best thing to do is to save the three files (the two .cpp files and the header file) somewhere, close VS, and from Windows Explorer, delete the directories.
Then start from scratch with a new project. If you have deleted the Temp directory and everything under it (after saving the three files I mentioned), you can
create a new empty project (you can call it Temp or whatever),
In VS, Add --> New items in the Source Files directory.
In VS, Add --> New items in the Include Files directory.
Copy each of the saved files into the source file and header file place-holders
Build.
View menu --> Solution Explorer
Thanks for the reply, I got back my Solution Explorer

No, it's from a working project. They all are this short. To confirm I am opening the right one, this is the one I open, this is a working project:
vcxproj.jpg


thanks for all the help.
 
  • #79
I still cannot get back to the original Solution Explorer like this that show Header file and Source file:
Solution Explorer.jpg

The solution Explorer that I got back using View-->Solution Explorer has less and not include like above as shown below. It's missing the two:
Solution Explorer short.jpg


I tried ADD --> Folder and just put back Header file and Source File? I did Add-->Existing on both Temp.cpp and Temp.h into the corresponding folder and ran. It works. Is that the right way?

Thanks
 
Last edited:
  • #80
yungman said:
The solution Explorer that I got back using View-->Solution Explorer has less and not include like above as shown below. It's missing the two:
In your 2nd screen shot, the one with Solution Explorer for your Temp project, just below where it says Solution Explorer, there are four icons. The fourth one, just to the right of the house icon, has a dropdown menu. This icon toggles between the VS solution hierarchy and the directory hierarchy. In the 2nd screen shot, you're showing the directory hierarchy. In the first screen shot, you're showing the solution hierarchy.
 
  • #81
Mark44 said:
In your 2nd screen shot, the one with Solution Explorer for your Temp project, just below where it says Solution Explorer, there are four icons. The fourth one, just to the right of the house icon, has a dropdown menu. This icon toggles between the VS solution hierarchy and the directory hierarchy. In the 2nd screen shot, you're showing the directory hierarchy. In the first screen shot, you're showing the solution hierarchy.
Thank Mark for all the help.
Now I know.

But I did something more stupid along the way last night. I think I deleted something. If I knew about toggling the hierarchy, I might not accidentally deleted the folder. Here is the screen shot of the Solution Hierarchy of Project2 that was working before. You can see the the Header folder and Source folder are all gone. There is no file in it. You can see below there there is no Header folder and Source folder. All the files have yellow triangle with '!', there is no file in them and obviously cannot compile, everything is gone.

This is Project2, it was a working program that I use Add--> Existing to link Temp.h to the Header folder and Temp.cpp and source.cpp to the Header folder from external folder. How do I get those back. I added back those folders manually, it worked last night, but I cannot repeat it on this project.

Solution Explorer short.jpg


Thanks
 
  • #82
Here's what I said before in post #77.
Mark44 said:
Best thing to do is to save the three files (the two .cpp files and the header file) somewhere, close VS, and from Windows Explorer, delete the directories.
Then start from scratch with a new project. If you have deleted the Temp directory and everything under it (after saving the three files I mentioned), you can
create a new empty project (you can call it Temp or whatever),
In VS, Add --> New items in the Source Files directory.
In VS, Add --> New items in the Include Files directory.
Copy each of the saved files into the source file and header file place-holders
Build.
Since we're just going around in circles, with little or no forward progress, I'm closing this thread.
 
  • Like
Likes Vanadium 50

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 33 ·
2
Replies
33
Views
3K
  • · Replies 6 ·
Replies
6
Views
12K
Replies
6
Views
2K
Replies
4
Views
5K
  • · Replies 8 ·
Replies
8
Views
4K