The prefix header functionality in Xcode comes in handy quite often and I was wondering if other IDEs provide a similar functionality? Or is there even a way on compiler level?
I've been looking for this in other environments for quite a time and the only thing I could find were precompiled headers. But that's not really the same as you still need to include the header file in each source file.
So, does anyone know if there's a way to configure prefix headers in IDEs like Visual Studio or QT Creator?
For VC++ you can specify Forced Include File using option /FI on command line or through an IDE. An excerpt from MSDN:
To set this compiler option in the Visual Studio development
environment:
1. Open the project's Property Pages dialog box.
2. Click the C/C++ folder.
3. Click the Advanced property page.
4. Modify the Force Includes property.
For QtCreator you can add two lines to your *.pro file:
CONFIG += precompile_header
PRECOMPILED_HEADER = stdafx.h
Of course, you can type any name instead of "stdafx.h"
Related
I recently downloaded Visual Studio Code to begin learning the C programming language. I installed the program as well as the C extension. However, when I tried to create the "Hello, World!" program, it would not run, and in the Problems menu it did not recognize the stdio.h header file, saying that I need to update my includePath. I have not been able to find any stdio.h file on my computer to link to. Do I need to download the C library files (even though I have read they should be included with the compiler), and if so, where can I find them? Or is there another solution? Thanks, and sorry if this is a stupid question, I am new to this.
I think you might be confusing VS Code with the VS IDE.
VS Code is a source editor only; that is to say that it's basically just a glorified text editor. It has the ability to load extensions and open a shell to compile the code, and there are a few extensions that let you debug the code itself, but they can be tricky to get setup and installed to work well with C/C++ code. VS Code does not have a compiler/assembler/linker nor the requisite headers or SDK's as that is up to you (the user) to install and then point to those in your settings file.
The Visual Studio IDE, on the other hand, is a complete integrated development environment that also includes the system headers and SDK's for Windows, as well as the binaries to properly compile, link and assemble your code into a binary for a Windows system (cross platform is possible as well). The Visual Studio IDE comes in many different flavors with the latest being VS 2017.
If you wish to stick with VS Code, you'll need to grab a compiler and the appropriate header files for the system you're targeting. If you wish to just stick with Windows for now, you can grab the Windows 7 SDK here or the Windows 10 SDK here .. you could even grab both and just reference the one you wish when you want. Note that the Windows 7 SDK includes the Microsoft C/C++ compiler, alternatively you can download the MSVC compiler from their Build Tools site.
There's also Cygwin in which you can use the GNU compiler, and of course Clang, which can be referenced in both VS Code and the VS IDE.
I hope that can help.
I'm looking to embed a DLL into the EXE of my WPF application so that I effectively only have 1 file to distribute, i.e. the .EXE. All of this stuff is completely over my head but I've followed the steps outlined in http://richarddingwall.name/2009/05/14/wpf-how-to-combine-mutliple-assemblies-into-a-single-exe/ but I still can't get this to work. Any ideas or help on this? As long as the DLL is in the same folder as EXE it works but if I remove the DLL, it will fail. However, I don't want the DLL to be present at all but rather embedded within the EXE. I've searched other posts here which recommend this solution but my problem is that everything compiles fine, it's just that it doesn't work and I don't know how to go about fixing it.
1) I have added the DLL in question as a resource to the project and set its Build Action to Embedded Resource
2) The code outlined in the above link, I've added to the App.xaml.cs file as well as using System.Reflection & System.IO
Is there anything esle I should be doing to get this to work?
Thanks
Shav
You could use ILMerge. We use it all the time to merge dll's into executable's and into other libraries.
Here's how someone else used ILMerge to accomplish this, so this could be considered a duplicate question.
If you are using Visual Studio w/Nuget, you can simply set your needed reference to 'copy local = true' and install Fody.Costura.
You can refine things a bit using a simple xml file, per the documentation provided on the project page (as well as tidy-up your build directory if desired).
I would like to do some C development in Windows environment using Visual Studio 2010. There are a few similar questions on this topic, but they are all based on that you are creating a Win32 console application, and a C++ project.
How can I do C development using only .c and .h files as I do in Unix? without creating a C++ projects containing tons of files.
It is possible to do C compiling with the cl compiler from outside of Visual Studio 2010, see Walkthrough: Compiling a C Program. But how can I do this compilation and execution/debugging from inside Visual Studio 2010?
UPDATE
I have tried to create a C++ project (Win32 Console Application) and only add .c files to it. It works but it creates tons of files.
I have tried with a C++ project (Empty project), but it also created a lot of project files.
Basically what I want is to only create .c and .h files, use the cl compiler, and use Visual Studio 2010 as a text editor. And use a command to compile from the text edior, but it seems like I have to compile in a command prompt.
File → New → Project...
Under C++, choose Empty Project. If you want to minimize the number of folders created, uncheck the box to Create Directory for Solution. Give the project a name and location and click OK.
In the Solution Explorer for the new project, right click Source Files and select Add → New Item.
Choose C++ File (.cpp), and give it a name like SomeName.c. Make sure to specify the .c extension. Add the following code:
int main(int argc, char** argv)
{
return 0;
}
If necessary, disable Microsoft extensions to the C language by right clicking the project and selecting Properties. Select All Configurations at the top of the dialog. Then go to C/C++ → Language → Disable Language Extensions: Yes.
Visual Studio will create the following files for your project. Just get used to having them there. Do not check items with a * into source control.
ProjectName.sln
ProjectName.sdf*
ProjectName.suo*
ProjectName.vcxproj
ProjectName.vcxproj.user*
ProjectName.vcxproj.filters
somename.c
If you compile a file that has the .c extension, VS will use it's C compiler. However, you should be aware that said C compiler isn't C99 conformant (or even C89 for some cases, if I remember correctly). Visual Studio is not really a C compiler, it's C++ mostly. You will have to use a C++ project and simply include .c files.
VS actually has a very capable C compiler, somethng that people overlook all too often. The above answers will point you in the right direction, but it's by no means low quality like I've heard people say in the past.
I'm new to Windows development, having messed around in Linux for a while. I need to access console functions and am having trouble getting a comprehensive list of console text attributes off the web. I would like to read wincon.h and windows.h to get the info, but I can't figure out how to get at them. Help please!
Windows does not come with these by default. If you are looking for them, you need to install the Windows SDK and dig around in the %PROGRAMFILES%\Microsoft SDKs\Windows directory.
They're normally stored along with the other SDK headers. Assuming you're using Visual Studio, the easy to look at them is to create a file, add a line to #include the file you care about, right click it, and click on the open document <whatever.h> line in the pop-up menu.
You'll have to install the Windows SDK to get the header files. Windows doesn't come with the software development tools out of the box and depending on which compiler you're using, they might not come with the compiler either.
I would try looking up the console function listing on MSDN
Do you know of any extension (desired free) for VS (or VCPP) 10 that adds C projects productivity (i.e. templates, headers control, syntax highlighting etc.)?
Thanks
Visual Studio already ships with support for C. That includes project files, a compiler, header files, syntax highlighting and debugging support. What are you missing (apart from C99)?
Create a standard C++ project such as a Win32 Console Application (it doesn't matter which one).
Add a new item (Project menu, Add New Item...) and select "C++ File (.cpp)"
Here is the important step. Give the file a ".c" extension rather than a ".cpp" extension. By calling the file ".c", Visual Studio will compile it as C instead of C++.
Create a Win32 C++ project and from the Solution Explorer right-click your projcet and select Properties -> Configuration Properties -> C/C++ -> Advanced -> Compile As -> Compile As C., then rename the *.cpp extensions to *.c and build your project.
You may want to delete some unimportant files like stadfx.cpp and targetver.h (remove its linkage from stdafx.h).