S
SJMcMullan
Guest
Hello. I'm used to using Visual Studio Code with command line compilers and debuggers, but now I want to learn to use a fully fledged IDE and I decided on Visual Studio. I only have two questions about developing Linux and Windows applications using :
#include <stdio.h>
#ifdef __linux__
#define OS Linux
int main(int argc, char* arg[])
{
printf("The OS is %s\n", OS);
return 0;
}
#elif _WIN32
#define OS Windows
int main(int argc, char* arg[])
{
printf("The OS is %s\n", OS);
return 0;
}
#endif
But when I try and run this, it gives me an error:
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-3.0.7-1/winsup/cygwin/lib/libcmain.c:37: undefined reference to `WinMain'
/usr/src/debug/cygwin-3.0.7-1/winsup/cygwin/lib/libcmain.c:37.text.startup+0x7f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
collect2: error: ld returned 1 exit status
What exactly am I doing wrong here? I'm trying to write a small program that will run differently on the two platforms: if running using Cygwin, it will print "The OS is Linux" but Windows will print "The OS is Windows".
2. I noticed that the Linux "section" of the code is darker than that of the Windows "section". How do I turn this off so that both are equally as bright?
Thanks.
Continue reading...
- I'm using Cygwin to compile and run the Linux code. An example of my code is:
#include <stdio.h>
#ifdef __linux__
#define OS Linux
int main(int argc, char* arg[])
{
printf("The OS is %s\n", OS);
return 0;
}
#elif _WIN32
#define OS Windows
int main(int argc, char* arg[])
{
printf("The OS is %s\n", OS);
return 0;
}
#endif
But when I try and run this, it gives me an error:
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-3.0.7-1/winsup/cygwin/lib/libcmain.c:37: undefined reference to `WinMain'
/usr/src/debug/cygwin-3.0.7-1/winsup/cygwin/lib/libcmain.c:37.text.startup+0x7f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
collect2: error: ld returned 1 exit status
What exactly am I doing wrong here? I'm trying to write a small program that will run differently on the two platforms: if running using Cygwin, it will print "The OS is Linux" but Windows will print "The OS is Windows".
2. I noticed that the Linux "section" of the code is darker than that of the Windows "section". How do I turn this off so that both are equally as bright?
Thanks.
Continue reading...