preprocessor directive #if

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
mahaju
Posts: 487
Joined: Mon 11 Oct 2010, 07:11
Location: between the keyboard and the chair

preprocessor directive #if

#1 Post by mahaju »

I saw

Code: Select all

#elif defined(TFM_X86_64)
in a very long sample code

is it same as

Code: Select all

#elif defined TFM_X86_64
??
Just checking

Thanks

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#2 Post by technosaurus »

I am away right now, Try:

#define TFM
#define _X86_64

#ifdef TFM_X86_64
printf("merged defs?");
#endif
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
mahaju
Posts: 487
Joined: Mon 11 Oct 2010, 07:11
Location: between the keyboard and the chair

#3 Post by mahaju »

Code: Select all

#include<stdio.h>
#define TFM
#define _X86_64

#ifdef TFM_X86_64
printf("merged defs?");
#endif
it says

Code: Select all

C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw
32.a(main.o):main.c:(.text+0x104): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
This is in gcc in Windows 7
Why isn't it compiling? The code looks simple enough

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#4 Post by technosaurus »

mahaju wrote:

Code: Select all

#include<stdio.h>
#define TFM
#define _X86_64

#ifdef TFM_X86_64
printf("merged defs?");
#endif
it says

Code: Select all

C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw
32.a(main.o):main.c:(.text+0x104): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
This is in gcc in Windows 7
Why isn't it compiling? The code looks simple enough
The ifdefs code needs to be in a main function ... I.figured if you were asking about ifdefs you would know that. Sorry, don't know the windows main functions.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
mahaju
Posts: 487
Joined: Mon 11 Oct 2010, 07:11
Location: between the keyboard and the chair

#5 Post by mahaju »

Oh Yeah
The main function
I knew I forgot something in this code :oops:

User avatar
mahaju
Posts: 487
Joined: Mon 11 Oct 2010, 07:11
Location: between the keyboard and the chair

#6 Post by mahaju »

Code: Select all

#include<stdio.h>
#define TFM
#define _X86_64

#ifdef TFM_X86_64
printf("merged defs?");
#endif

int main(){return 0;}
Compiles fine
When I run it my AVG 2011 Free Edition antivirus says it's potential threat

What happened here??

And then same for

Code: Select all

#include<stdio.h>
int main(){
	#define TFM
	#define _X86_64

	#ifdef TFM_X86_64
	printf("merged defs?");
	#endif
	return 0;
}
Why is that?

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#7 Post by technosaurus »

Did it print "merged defs" on the command line?
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
mahaju
Posts: 487
Joined: Mon 11 Oct 2010, 07:11
Location: between the keyboard and the chair

#8 Post by mahaju »

No
The antivirus is blocking it (1st code)
and the second one says "Access Denied" when it is run, then it's blocked by the antivirus
and it's not because my computer's infected either, I can compile all other code using gcc and none of them show up as Potential threats in the antivirus
I think it's got something to do with those predefined macro names

OK I changed the macro names into some random texts and it's still showing the same problems why is that?

User avatar
mahaju
Posts: 487
Joined: Mon 11 Oct 2010, 07:11
Location: between the keyboard and the chair

#9 Post by mahaju »

Ok

I tried both the codes given above in Windows XP as well as puppy Linux 5.2.8 in VMWare player. They don't have antivirus installed so compiled executable is not blocked, however, it doesn't apparently do anything

Why is it like this?

Post Reply