Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Conditional compilation in C

Name: Anonymous 2012-02-05 5:05

How exactly does conditional compilation works in C?

I'm using GMP to do some calculations in a C program;
but if GMP isn't available in the machine, I could do the calculations with some handmade functions.

Any help would be great. Thanks in advance!

Name: Anonymous 2012-02-05 5:10

Google for C preprocessor.

example:

#ifdef CAN_HAS_GMP
#define DO_SJIT gmp_do_shit
#else
#define DO_SJIT handmade_do_shit
#endif

void fun()
{
    DO_SJIT(some parameter shit);
}

Name: Anonymous 2012-02-05 5:10

>>1
If the __GNU_MP_VERSION macro is available use GMP, else use your handmade magic.

Name: Anonymous 2012-02-05 11:30

>>2
That's not correct. Again, perhaps you should just shut up on something you clearly have no clue about.

Name: Anonymous 2012-02-05 11:51

>>2
You.. helped.. him? Shinjirarenai!

Name: kodak_gallery_programmer !!qmiXqQhekkGXVVD 2012-02-05 11:55

>>5
>>2 approach isn't correct.

Name: Anonymous 2012-02-05 12:17

>>4

It is correct. Prove me otherwise.

Name: Anonymous 2012-02-05 12:21

>>7
What happens if I use those flags in a makefile and then port this to a different OS that doesn't support GMP? Exactly. Perhaps you should shut up and try it before opening your mouth again.

Name: Anonymous 2012-02-05 13:05

If you do it during the compilation stage, you will not be able to distribute your binary. It is better to handle it at runtime, either via weak linking on platforms that support it, or by manually loading the dynamic library.

Though realistically, if you need GMP your own replacements aren't going to be worth shit.

Name: Anonymous 2012-02-05 13:08

>>8
why would you use CAN_HAS_GMP flag in a makefile?

Why do you purposefully try to break stuff?

Name: Anonymous 2012-02-05 13:10

>>9
If you do it during the compilation stage, you will not be able to distribute your binary.

If >>2 would have gotten the conditional guards right, it would have been possible to do this during the compilation state, and like uh... thus be able to distrube the binary. Geeze. Both you and >>2 speak from inexperience or some shit like that.

Name: Anonymous 2012-02-05 13:12

>>10
Because it's standard practice you idiot. Oh wait, you aren't aware of something like this because you don't work as a computer programmer. Instead, you're just some idiot toilet scrubber that googles shit.

Name: Anonymous 2012-02-05 13:13

>>11
2/10, try harder.

Name: Anonymous 2012-02-05 13:13

2012, using GNU C

Name: Anonymous 2012-02-05 13:14

>>13
Haven't you ever read the source code to a major piece of software? If you have, you wouldn't have made such an ignorant and idiotic statements.

Name: Anonymous 2012-02-05 13:16

>>12
Actually kodak-kun, i'm a project manager that tells you codemonkeys to make my projects for me. If anyone is the toilet scubbers then it's you.


Enjoying that enterprise java codemonkey job of yours? yeah go fuck off you piece of shit. You're not special, you're replaceable.

Name: Anonymous 2012-02-05 13:18

>>16
Then why make such ignorant and idiotic statements? Wtf? Are you just having GW Bush? Or are you just trolling?

Name: Anonymous 2012-02-05 13:22

>>17
I haven't made any statements in this thread until >>16

I'm tired of seeing your bullshit of telling other codemonkeys that they are toilet scrubbers when all you are toilet scrubbing codemonkeyes.

Name: Anonymous 2012-02-05 13:26

>>18
Well, it's rocket science to see that >>2 is totally clueless.

Name: Anonymous 2012-02-05 13:30

>>15
You don't even understand the post you're replying to.

Name: Anonymous 2012-02-05 13:32

>>20
Huh? I'm not the moron that is making ignorant statements. Now hush up and try to learn something from this thread you fucking idiot.

Name: Anonymous 2012-02-05 13:34

This thread sucks. Let's talk about subsets.

Name: Anonymous 2012-02-05 13:36

>>22
You're just mad because I'm talking about something that is outside of your limited skill set.

Name: Anonymous 2012-02-05 13:44

>>23
But I'm not mad, and that was my first post in this thread.

Name: Anonymous 2012-02-05 13:51

>>21
Responding to a substandard troll, but..
With only compile-time checking, a binary build with GMP support will not run on a machine without GMP installed (unless you're linking statically, which you shouldn't). With runtime checks, you can gracefully fall back with reduced functionality.

Name: Anonymous 2012-02-05 13:56

>>25
3/10. Keep studying wikipedia there buddy.

Name: Anonymous 2012-02-05 13:57

>>26
You're really, really bad at that.

Name: Anonymous 2012-02-05 14:17

>>27
I'm not the foolholio that is making retarded ass statements. Why don't you just give google a rest, and like, try and write some actual C code.

Name: Anonymous 2012-02-05 14:25

>>14
Using GMP doesn't make your program GNU-C you stupid piece of shit.

Name: Anonymous 2012-02-05 14:28

>>28
Both boring and unoriginal.

Name: Anonymous 2012-02-05 14:31

>>30
I'm being serious. So once again, you're stupid. And once again, you have no possible future as a computer programmer. This is partly due to the fact that you're lazy and unmotivated.

Name: Anonymous 2012-02-05 14:34

>>33
kawaii dubs, oniichan

Name: Anonymous 2012-02-05 15:49

>>32
Thanks, faggot.

Name: Anonymous 2012-02-05 16:39

O... kay... OP here.

So, what should I do in this case? >>2, >>3 or none?

Name: Anonymous 2012-02-05 16:47

>>34

None. Go to StackOverflow and ask.

Name: Anonymous 2012-02-06 10:22

>>35
Nigger, please.

Name: Anonymous 2012-02-06 11:31

>>34
Well, you combine them and use #ifdef __GNU_MP_VERSION

CAN_HAS_GMP was just an example

Don't change these.
Name: Email:
Entire Thread Thread List