Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I unable to #ifdef stdafx.h?

I am trying to include 2 platform-specific stdafx.h files in my .cpp file, but the compiler is unhappy when I try to #ifdef it.

#ifdef _WIN32
#include "stdafx.h"
#elif _MAC
#include "MAC/stdafx.h"
#endif

You may wonder why I am using stdafx.h in the Mac code, but that is not important at the moment :).

When I try to compile the code on Windows, I receive: Fatal Error C1018. I tried enclosing other header files with #ifdef in the same file, and the compiler was happy. Therefore, it looks like Windows doesn't like stdafx.h to be #ifdef-ed, or that Windows only allows #include stdafx.h to be the first line in the file.

So my question is, why?

Kat

like image 214
kyue Avatar asked Sep 16 '09 22:09

kyue


People also ask

Why do I suddenly lose focus?

Such symptoms may be due to an underlying condition, like mild cognitive impairment, or a mood disorder, like depression and anxiety. Declining focus also could result from lifestyle issues that should be addressed, such as stress, fatigue, poor sleep, dehydration, an unhealthy diet, or sedentary behavior.

What is it called when you lose focus easily?

attention deficit hyperactivity disorder (ADHD)

Why is it hard for me to focus on one thing?

Lack of sleep. It's tough to pay attention when you're tired. That's because your brain cells recharge and recover when you're asleep. They don't work as well when you don't get enough rest. Research shows that skipping even one night of sleep makes it harder to focus and block out distractions.

What illness causes lack of concentration?

Attention-deficit/hyperactivity disorder (ADHD)


1 Answers

When the compiler includes a pre-compiled header, it basically "forgets" anything that came before the header. Thus your #elif isn't matched to a #if anymore.

like image 66
Mark Ransom Avatar answered Oct 06 '22 23:10

Mark Ransom