I'm programming in C++ on Visual Studio 2005. My question deals with .rc files. You can manually place include directives like (#include "blah.h"), at the top of an .rc file. But that's bad news since the first time someone opens the .rc file in the resource editor, it gets overwritten. I know there is a place to make these defines so that they don't get trashed but I can't find it and googling hasn't helped. Anyone know?
Add your #include to the file in the normal way, but also add it to one the three "TEXTINCLUDE" sections in the file, like so:
2 TEXTINCLUDE
BEGIN
"#include ""windows.h""\r\n"
"#include ""blah.h\r\n"
"\0"
END
Note the following details:
Each line is contained in quotes
Use pairs of quotes, e.g., "" to place a quote character inline
End each line with \r\n
End the TEXTINCLUDE block with "\0"
Statements placed in the "1 TEXTINCLUDE" block will be written to the beginning of the .rc file when the file is re-written by the resource editor. Statements placed in the 2 and 3 blocks follow, so you can guarantee relative include file order by using the appropriately numbered block.
If your existing rc file does not already include TEXTINCLUDE blocks, use the new file wizard from the Solution Explorer pane to add a new rc file, then use that as a template.
You want to Include Resources at Compile Time (MSDN).
Within Visual Studio IDE, right-click on the .rc file (in the Resource View panel), and select "Resource includes" from the shortcut menu. When the dialog opens, use its "Compile-time directives" area to enter whatever you want to include in the .rc file. For example, if you want your 64-bit and 32-bit builds to use different icons, you could include the appropriate resource file for each build as follows:
#ifdef WIN64
#include "Icons64.rc"
#else
#include "Icons32.rc"
#endif
It's worth noting that these defines are not set in the resource compiler by default, so for your 64 bit build make sure you add /DWIN64 to the rc build.
All the gory details can be found in MFC Technote #35.
-Ron
I'm not completely sure why you're trying to do, but modifying the resource files manually probably isn't a good idea.
I believe general practice for VC++ for globally-accessible values is to define them in stdafx.h (at least that's how I've seen it done), or to create something like a "globals.h" header file and include that wherever you need it. It really depends on what you're trying to accomplish though.
Related
Hi I currently have a uni course in f#, where i need to use a .dll file that my professor made, in my code. In this picture, the parser.dll file has a red circle around it, and the current f# file has a blue:
Now the parser.dll is a parser that i need to pass some strings to, and get some output in my f# program.
My professor is for some reason able to acces this file by simply putting the parser.dll file in the current directory. When i do this in visual studio, the .dll file is hidden in the file explorer, and i am not ablue to acces it in the code either.
Now i could read some places that it could be a good idea to create references to it in the solution explorer>add>Reference>Browse, and try to find it on my machine (tried a few different locations), it is still hidden to me in the browse tool.
What is the best thing for me to do? and why is my dll file hidden from me when I attempt to add it using the "browse feature"?
Thank you
The other answers i've seen proved to be ineffective.
I'm using c++ and it gives me error(red squiggle) when i include vector or string.
It tells me that my include path is not updated so i click on the lightbulb and try to edit intellisense configurations.
In this window there's an include path section, inside the box there's this string: ${workspaceFolder}/**.
So is this string the problem?
I've tried to put in this box the following path as well:
/usr/local/include but it doesn't change anything...
Please what should i change about this include path??
What is there supposed to be in it?
Press Ctrl+Shift+P to open the Command Palette
Start typing "C/C++" and then choose Edit Configurations (UI) from the list of suggestions. This opens the C/C++ Configurations page. When you make changes here, VS Code writes them to a file called c_cpp_properties.json in the .vscode folder.
Find the Compiler path setting. VS Code will attempt to populate it with a default compiler based on what it finds on your system. For Clang on macOS, the path should look like this: /usr/bin/clang.
The Compiler path setting is the most important setting in your configuration. The extension uses it to infer the path to the C++ standard library header files. When the extension knows where to find those files, it can provide lots of useful information to you as you write code.
Set IntelliSense mode to ${default}, which on macOS is clang-x64.
You only need to modify the Include path setting if your program includes header files that are not in your workspace or in the standard library path.
On macOS, you must set the macFrameworkPath to point to the system header files.
Visual Studio code places these settings in .vscode/c_cpp_properties.json.
Original documentation here!
I just set up a new project from this repository in Visual Studio Community 2015. Looking at the Solution Explorer, every single header file from this repository is included in the project.
However, opening a file (for example, atomic.h), will lead to most include directives being underlined in red with a mouseover-text cannot open source file "...". Continuing with the example file:
#ifndef ATOMIC_H
#define ATOMIC_H
#include "quantum.h" //underlined
#include <stddef.h> //not underlined
Yet the file is most certainly included in the project. It can be seen in the "Header Files" filter in the Solution Explorer. And it is included in the .vcxproj file:
<ItemGroup>
[...]
<ClInclude Include="quantum\quantum.h" />
[...]
</ItemGroup>
According to this answer, the inclusion of a file using the ClInclude tag should be enough to let IntelliSense find it, but it somehow doesn't seem to.
I can fix this by including every single folder and sub-folder separately in the VC++ Include Directories as mentioned here but that would take me hours. I also changed the double quotes to angled brackets, but that didn't help and I don't want to do that on a repo that I'm going to commit to either when it's working for everybody else.
Is there any way I can point IntelliSense to all the files that are obviously included in the project?
There's no need to build with MSVC, I only want IntelliSense to work properly.
I downloaded the example that you provided and got the same result like yours, from the .vcxproj file, the ‘ClInclude’ child element is under ‘ItemGroup’ element. This child element specifies the name of the header file for the C/C++ source file, we can know it from this, not means it will be auto complied.
We still need to add those parent folders of each #include "xxx.h" into the Node ‘AdditionalIncludeDirectories’ like you found. When you added it, then build and check the .vcxproj file, the addition include directory information should display like the following:
It will be a huge job to add those required folders into the Node ‘AdditionalIncludeDirectories’, you need to search the ‘xxx.h’ and find the record under ‘ClInclude’, copy the parent folder of this file and add into the node ‘AdditionalIncludeDirectories’ like the above, then reload the project and the intellisense works fine.
I have read that it is bad to edit the UIMap.Designer.cs file, however, I do not understand why.
Per MSDN:
"Do not modify the UIMap.designer.cs file directly. If you do this, the changes to the file will be overwritten." http://msdn.microsoft.com/en-us/library/dd380782.aspx
Does anybody know what gets overwritten? Does this mean that if the UIMap.uitest file is edited after the Designer file, the designer file gets reversed? please help.
The UIMap.designer.cs file is regenerated from the UIMap.uitest file after every edit (that is saved) to the UIMap.uitest file. There is a comment at the top of the file saying that it is a generated file and that edits will be lost.
Large numbers of changes that, at first sight, appear to need editing of code in the designer file can be done by editing via the properties panels of the actions and UI-controls shown in the UIMap editor. Some changes do need manual editing. For these there is a command (button or right-click-menu) to move an action into the UIMap.cs file where it can be edited and extended as much as desired. Both of these UIMap...cs files specify partial in their class headers so both contribute to the same UIMap.
When just one action of a method needs manual editing it can be worth splitting that method into two or three pieces to place the action needing edits into its own method. The split command is available via a button or the right-click-menu. Having isolated the action, its method can be moved into the UIMap.cs file.
When moving methods and then editing them I recommend the following order of activity.
If needed: Split the method into pieces then rename the split methods using the UIMap editor. Save the UIMap.uitest file causing regeneration of the designer file. Then add calls to the split and renamed methods. Build the test and, perhaps, check that the test still works as expected.
Move method into the UIMap.cs file using the UIMap editor.
Save all files causing regeneration of the designer file. Omitting this save-all can cause confusing errors to be displayed on the C# files.
Edit the code just moved into the UIMap.cs file.
The UI Map editor is standard with Visual Studio 2012. For Visual Studio 2010 the editor was added by Feature Pack 2.
another option is to create another Class file for example, create Class1.CS and move all the code from UIMap.Designer.cs and UIMap.cs to Class1.cs. Now whenever you record anything, the regenerated code will be automatically generated in UIMap.Designer.cs file so just copy the same code to Class1.cs and change the code there if needed, and while running the main test just call this.Class1.launch(); it will run the codedTest.
It will also save you from splitting of methods in UIMap.uitest and then moving it to UIMap.cs
and even there will be a separate class including all your changes to the codedUItest.
Open the UIMap.uitest file in Visual Studio and click the 'Move code to UIMap.cs'
your function will move from designer.cs to UiMap.cs
So I've written code in OpenCV which contains 2 header files using Code::Blocks. When I compile the files, there are no errors except two "undefined reference..." errors which occur because I have used functions that I have declared in the header files. I assumed that code blocks automatically linked the header files? I have used the "#include.." to include the header files at the top of the programs so not sure what the problem could be. Anyone have any idea? Thanks.
I was having a similar problem, but happened upon a solution
Click the "Project" tab, it's in the top right side.
Within the "Project" tab click the "Add Files..." option.
Highlight your Header file and any other files associated with your header file, like if you put your header files definitions in a .cpp file.
Compile and Run.
Hopefully this helps, it worked for me but our issues could be different.