Linked Questions

1 vote
2 answers
500 views

I need to figure out the operating system my program is running on during runtime. I'm using Qt 4.8.1, MinGW. My program shall run a command-line QProcess on Windows or Linux. Now I need a kind of ...
elgolondrino's user avatar
324 votes
20 answers
233k views

I need my code to do different things based on the operating system on which it gets compiled. I'm looking for something like this: #ifdef OSisWindows // do Windows-specific stuff #else // do Unix-...
perimosocordiae's user avatar
227 votes
7 answers
274k views

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
124 votes
8 answers
115k views

What is the most reliable way to find out CPU architecture when compiling C or C++ code? As far as I can tell, different compilers have their own set of non-standard preprocessor definitions (_M_X86 ...
Alex B's user avatar
  • 85.4k
39 votes
9 answers
67k views

I would like to detect whether the OS I'm compiling on is Windows. Is there a simple macro I can check to verify that?
batty's user avatar
  • 7,856
17 votes
3 answers
23k views

I am using mingw32-make to compile a project to Windows, which depends on a project called libevent2. I keep receiving this error - util.h:69:25: fatal error: sys/socket.h: No such file or directory ...
liamzebedee's user avatar
  • 14.6k
4 votes
1 answer
4k views

How might I write a single header file that defines an interface and use a separate source files to write platform-specific code? For example: video.h video_windows.c video_linux.c video_osx.c
user avatar
4 votes
1 answer
7k views

I want to use a RAW Socket in Visual C++. I saw a function on Linux which is int out = socket(AF_INET, SOCK_RAW, htons(ETH_P_ALL)); Using this code in linux we can do that, but how to use RAW SOCKET ...
Chandrapal Singh Jhala's user avatar
1 vote
2 answers
3k views

So i'd like to build my application to be Platform Independent such that it can run on Windows, OSX, Linux etc. For example one of the main "parts" that is different across the platforms is a Window. ...
Jon's user avatar
  • 283
4 votes
2 answers
2k views

I'm looking for a way for basic management of processes in a cross platform way in C++, but I can't use external libraries (like boost::process). The scenario is this - i'm calling a child process ...
Vlad Keel's user avatar
  • 410
1 vote
3 answers
675 views

I have just been using the #define to change my values ex: #include <iostream> #include <string> #define Changed_num 100 using namespace std; int main () { ...
LostPecti's user avatar
  • 121
2 votes
1 answer
2k views

I'm currently trying to get some C code that I originally wrote for linux (gcc) to build on a win32 box. The MSVC compiler is giving me warnings for all my printf and scanf usage suggesting I should ...
bph's user avatar
  • 11.4k
2 votes
1 answer
600 views

Dear All I have a small Fortran program containing preprocessor macro. Below is a minimal example. On mac os x, it works well but when I compile it on windows 7 (64-bit) it always prints unknown ...
UCU110's user avatar
  • 413
0 votes
3 answers
471 views

Recently, I was learning about networking in C++ and I found boost.asio which is a cross platform library, and then I got a thought about how this library is a cross platform since Windows provides ...
The RESEARCHER's user avatar
0 votes
1 answer
267 views

Here is a snapshot of a function that I am porting to my Windows machine from here using Visual Studio. bool MinidumpFileWriter::Open(const char *path) { assert(file_ == -1); #if __linux__ file_ =...
user1343318's user avatar
  • 2,141

15 30 50 per page