All Questions

Tagged with
Filter by
Sorted by
Tagged with
241 votes
13 answers
201k views

What's the best free C++ profiler for Windows? [closed]

I'm looking for a profiler in order to find the bottleneck in my C++ code. I'd like to find a free, non-intrusive, and good profiling tool. I'm a game developer, and I use PIX for Xbox 360 and ...
223 votes
10 answers
427k views

Is there a replacement for unistd.h for Windows (Visual C)?

I'm porting a relatively simple console program written for Unix to the Windows platform (Visual C++ 8.0). All the source files include "unistd.h", which doesn't exist. Removing it, I get ...
AShelly's user avatar
  • 35k
220 votes
7 answers
258k views

C++ compiling on Windows and Linux: ifdef switch [duplicate]

I want to run some c++ code on Linux and Windows. There are some pieces of code that I want to include only for one operating system and not the other. Is there a standard #ifdef that once can use? ...
Sardathrion - against SE abuse's user avatar
189 votes
17 answers
341k views

The program can't start because libgcc_s_dw2-1.dll is missing

I have created a simple program in C++ with Code::Blocks. If I run it from Code::Blocks, it works correctly; but if I run it by doubleclicking on the executable file, a window pops up with this ...
xRobot's user avatar
  • 26.1k
184 votes
16 answers
217k views

Fastest method of screen capturing on Windows

I want to write a screencasting program for the Windows platform, but am unsure of how to capture the screen. The only method I'm aware of is to use GDI, but I'm curious whether there are other ways ...
someguy's user avatar
  • 7,274
177 votes
15 answers
203k views

How to debug heap corruption errors?

I am debugging a (native) multi-threaded C++ application under Visual Studio 2008. On seemingly random occasions, I get a "Windows has triggered a break point..." error with a note that this ...
user avatar
173 votes
8 answers
691k views

"X does not name a type" error in C++

I have two classes declared as below: class User { public: MyMessageBox dataMsgBox; }; class MyMessageBox { public: void sendMessage(Message *msg, User *recvr); Message receiveMessage(); ...
Rakesh K's user avatar
  • 8,325
163 votes
15 answers
178k views

Fatal error: "No Target Architecture" in Visual Studio

When I try to compile my c++ project using Visual Studio 2010 in either Win32 or x64 mode I get the following error: >C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(135): ...
philipvr's user avatar
  • 6,058
161 votes
15 answers
158k views

What is the closest thing Windows has to fork()?

I guess the question says it all. I want to fork on Windows. What is the most similar operation and how do I use it.
rlbond's user avatar
  • 66.7k
158 votes
8 answers
237k views

What is the bit size of long on 64-bit Windows?

Not to long ago, someone told me that long are not 64 bits on 64 bit machines and I should always use int. This did not make sense to me. I have seen docs (such as the one on Apple's official site) ...
user avatar
155 votes
22 answers
341k views

Qt 5.1.1: Application failed to start because platform plugin "windows" is missing

Edit: Some people started to mark my question as a duplicate. Do not forget that many similar questions existed when I asked this one (see e.g. the list below). However, none of these answers solved ...
Anonymous's user avatar
  • 4,697
137 votes
6 answers
224k views

LPCSTR, LPCTSTR and LPTSTR

What the difference between LPCSTR, LPCTSTR and LPTSTR? Why do we need to do this to convert a string into a LV / _ITEM structure variable pszText: LV_DISPINFO dispinfo; dispinfo.item.pszText = ...
nothingMaster's user avatar
136 votes
9 answers
252k views

How to convert std::string to LPCSTR?

How can I convert a std::string to LPCSTR? Also, how can I convert a std::string to LPWSTR? I am totally confused with these LPCSTR LPSTR LPWSTR and LPCWSTR. Are LPWSTR and LPCWSTR the same?
Cute's user avatar
  • 13.8k
128 votes
4 answers
40k views

How do I safely pass objects, especially STL objects, to and from a DLL?

How do I pass class objects, especially STL objects, to and from a C++ DLL? My application has to interact with third-party plugins in the form of DLL files, and I can't control what compiler these ...
cf-'s user avatar
  • 8,768
128 votes
20 answers
413k views

How can I clear console

As in the title. How can I clear console in C++?
Thomas B's user avatar
  • 1,309
120 votes
15 answers
943k views

Run C++ in command prompt - Windows

I know that everyone uses an IDE nowadays, but I just find it simpler to write my code in notepad++, compile it using a command prompt command, and run it from there too. At least that works for Java ...
Bluefire's user avatar
  • 13.8k
111 votes
5 answers
56k views

How does the Import Library work? Details?

I know this may seem quite basic to geeks. But I want to make it crystal clear. When I want to use a Win32 DLL, usually I just call the APIs like LoadLibrary() and GetProcAdderss(). But recently, I ...
smwikipedia's user avatar
  • 63.2k
107 votes
24 answers
457k views

How to get Current Directory?

I want to create a file in the current directory (where the executable is running). My code: LPTSTR NPath = NULL; DWORD a = GetCurrentDirectory(MAX_PATH,NPath); HANDLE hNewFile = CreateFile(NPath,...
Ivan Prodanov's user avatar
104 votes
8 answers
187k views

How to read a value from the Windows registry

Given the key for some registry value (e.g. HKEY_LOCAL_MACHINE\blah\blah\blah\foo) how can I: Safely determine that such a key exists. Programmatically (i.e. with code) get its value. I have ...
nolandda's user avatar
  • 2,254
102 votes
4 answers
210k views

How to use QueryPerformanceCounter?

I recently decided that I needed to change from using milliseconds to microseconds for my Timer class, and after some research I've decided that QueryPerformanceCounter is probably my safest bet. (The ...
Anonymous's user avatar
  • 4,187
100 votes
3 answers
150k views

How to use Libraries

For some reason I'm never able to use external libraries in any language. I'm looking for instructions/explanations of how to use external libraries, as well as how they work. When I search online, I ...
sinθ's user avatar
  • 11.3k
95 votes
8 answers
70k views

How should I use FormatMessage() properly in C++?

Without: MFC ATL How can I use FormatMessage() to get the error text for a HRESULT? HRESULT hresult = application.CreateInstance("Excel.Application"); if (FAILED(hresult)) { // what should ...
Aaron's user avatar
  • 2,853
95 votes
13 answers
63k views

LLVM C++ IDE for Windows

Is there some C/C++ IDE for Windows, which is integrated with the LLVM compiler (and Clang C/C++ analyzer), just like modern Xcode do. I have Dev-Cpp (it uses outdated GCC) and Code::Blocks (with ...
osgx's user avatar
  • 92.1k
95 votes
4 answers
2k views

Manipulate system/visible clipping region in Windows 1809

Apparently, Microsoft has changed the way clipping works with Windows update 1809, released in late 2018. Before that update, GetClipBox() returned the full client rectangle of a window, even when it ...
Johannes Stricker's user avatar
93 votes
3 answers
60k views

__cdecl or __stdcall on Windows?

I'm currently developing a C++ library for Windows which will be distributed as a DLL. My goal is to maximize binary interoperability; more precisely, the functions in my DLL must be usable from code ...
Etienne Dechamps's user avatar
92 votes
9 answers
61k views

What is the meaning and usage of __stdcall?

I've come across __stdcall a lot these days. MSDN doesn't explain very clearly what it really means, when and why should it be used, if at all. I would appreciate if someone would provide an ...
vehomzzz's user avatar
  • 43.7k
92 votes
3 answers
9k views

<random> generates same number in Linux, but not in Windows

The code below is meant to generate a list of five pseudo-random numbers in the interval [1,100]. I seed the default_random_engine with time(0), which returns the system time in unix time. When I ...
Amin Mesbah's user avatar
91 votes
10 answers
261k views

Create a directory if it doesn't exist

In my app I want to copy a file to the other hard disk so this is my code: #include <windows.h> using namespace std; int main(int argc, char* argv[] ) { string Input = "C:\\Emploi NAm....
pourjour's user avatar
  • 1,216
91 votes
5 answers
60k views

What is the difference between WM_QUIT, WM_CLOSE, and WM_DESTROY in a windows program?

I was wondering what the difference between the WM_QUIT, WM_CLOSE, and WM_DESTROY messages in a windows program, essentially: when are they sent, and do they have any automatic effects besides what's ...
user avatar
91 votes
7 answers
51k views

When and how should I use exception handling?

I am reading about exception handling. I got some information about what exception handling is, but I have a few questions: When to throw an exception? Instead of throwing an exception, can we use a ...
Umesha MS's user avatar
  • 2,881
90 votes
11 answers
62k views

Can I get Memcached running on a Windows (x64) 64bit environment?

Does anyone know IF, WHEN or HOW I can get Memcached running on a Windows 64bit environment? I'm setting up a new hosting solution and would much prefer to run a 64bit OS, and since it's an ASP.Net ...
RobertTheGrey's user avatar
89 votes
12 answers
49k views

Is TCHAR still relevant?

I'm new to Windows programming and after reading the Petzold book I wonder: is it still good practice to use the TCHAR type and the _T() function to declare strings or should I just use the wchar_t ...
Fábio's user avatar
  • 3,389
87 votes
7 answers
99k views

Export all symbols when creating a DLL

With VS2005, I want to create a DLL and automatically export all symbols without adding __declspec(dllexport) everywhere, and without hand-creating .def files. Is there a way to do this?
Jazz's user avatar
  • 5,817
84 votes
7 answers
113k views

WINMAIN and main() in C++ (Extended)

Right, I have looked at this post: Difference between WinMain,main and DllMain in C++ I now know that WINMAIN is used for window applications and main() for consoles. But reading the post doesn't ...
Danny's user avatar
  • 9,385
81 votes
5 answers
124k views

Detect Windows or Linux in C, C++ [duplicate]

I am writing a cross platform program. I want this one program to run under both Windows and Linux, so I have two different code segments for the two platforms. If the OS is Windows, I want the first ...
Ronin's user avatar
  • 2,047
80 votes
4 answers
75k views

Is there a way to get the string representation of HRESULT value using win API?

Is there a function in win API which can be used to extract the string representation of HRESULT value? The problem is that not all return values are documented in MSDN, for example ...
khkarens's user avatar
  • 1,325
80 votes
9 answers
119k views

Refreshing the auto complete (IntelliSense) database in Visual Studio

I've noticed that the auto complete feature in Visual Studio no longer works properly once my project has reached a certain size (in my case ~4,100 lines of code). I've also noticed that performance ...
Sebi's user avatar
  • 4,402
80 votes
13 answers
49k views

rc.exe no longer found in VS 2015 Command Prompt

I just installed Windows 10 Creators Update (version 10.0.15063). I have multiple versions of Visual Studio installed (2012, 2013, 2015 and 2017). I installed VS 2017 only a couple weeks ago. ...
François Beaune's user avatar
79 votes
2 answers
36k views

Problem calling std::max

I compiled my bison-generated files in Visual Studio and got these errors: ...\position.hh(83): error C2589: '(' : illegal token on right side of '::' ...\position.hh(83): error C2059: syntax ...
Haiyang's user avatar
  • 1,527
77 votes
8 answers
85k views

GCC worth using on Windows to replace MSVC?

I currently develop in C++ on Windows, using Visual Studio 2010. After the official announcement of C++11, I have begun to use some of its features that are already available in MSVC. But, as expected,...
Nairou's user avatar
  • 3,655
76 votes
6 answers
78k views

Linking different libraries for Debug and Release builds in Cmake on windows?

So I've got a library I'm compiling and I need to link different third party things in depending on if it's the debug or release build (specifically the release or debug versions of those libraries). ...
gct's user avatar
  • 14.3k
76 votes
7 answers
76k views

How to open an std::fstream (ofstream or ifstream) with a unicode filename?

You wouldn't imagine something as basic as opening a file using the C++ standard library for a Windows application was tricky ... but it appears to be. By Unicode here I mean UTF-8, but I can convert ...
Andrew Beatty's user avatar
75 votes
13 answers
161k views

C++, How to determine if a Windows Process is running?

This is concerning Windows XP processes. I have a process running, let's call it Process1. Process1 creates a new process, Process2, and saves its id. Now, at some point Process1 wants Process2 to ...
Pedro's user avatar
  • 759
74 votes
44 answers
1.2m views

Best C++ IDE or Editor for Windows

What is the best C++ IDE or editor for using on Windows? I use Notepad++, but am missing IntelliSense from Visual Studio.
74 votes
3 answers
29k views

What does it mean to set the declaration of a function equal to 0? How can you assign an integer to a function?

I was browsing through the sources of a (prefer not to name) GUI Toolkit which wrapped up the Windows API when I found the following function definition in the window class: virtual LRESULT CALLBACK ...
ApprenticeHacker's user avatar
74 votes
2 answers
18k views

know if .lib is static or import

I have .lib file compiled from C code. How I know if this self-contained static library or just an import lib and DLL will be needed at runtime? Is there some dumpbin option I'm missing?
zaharpopov's user avatar
  • 17.1k
72 votes
6 answers
81k views

What are the definitions for LPARAM and WPARAM?

I know I'm being lazy here and I should trawl the header files for myself, but what are the actual types for LPARAM and WPARAM parameters? Are they pointers, or four byte ints? I'm doing some C# ...
Mark Heath's user avatar
  • 48.9k
72 votes
6 answers
196k views

cmake - find_library - custom library location

I'm currently trying to get CMake running for my project (on windows). I want to use a custom location where all libraries are installed. To inform CMake about that path I tried to do that: set(...
Daniel's user avatar
  • 3,053
71 votes
7 answers
154k views

How to get main window handle from process id?

How to get main window handle from process id? I want to bring this window to the front. It works well in "Process Explorer".
Alexey Malistov's user avatar
70 votes
4 answers
36k views

Have a static lib, is there a simple way to know it is for 32 bit or 64 bit?

Is there any tool that can directly test if a library is made for 32 or 64 bit?
user705414's user avatar
  • 20.9k

1
2 3 4 5
461