Jump to content
Sign in to follow this  
faguss

OFP Preprocessor Explained

Recommended Posts

Sanctuary asked me to start a topic about so here it is.

OFP Preprocessor Explained (last update 21th September 2011).

This is for Flashpoint, not for ARMA!

Edited by Faguss

Share this post


Link to post
Share on other sites

Thanks Faguss. Are there any detailed examples

that could be included with a description of the

benefits gained by using the PreProcessor?

The Bohemia Interactive Community Wiki

also has some OFP specific PreProcessor

reference documentation:

preprocessFile:

http://community.bistudio.com/wiki/preprocessFile

PreProcessor Commands:

http://community.bistudio.com/wiki/PreProcessor_Commands

PreProcessor Errors:

http://community.bistudio.com/wiki/PreProcessor_Errors

Share this post


Link to post
Share on other sites

A practical example of one of the commands explained in Faguss excellent PDF at "10. #ifdef, #endif – conditional inclusion" is what i used for the GRAA mod option system.

By example, in the config.cpp of the mode , there's a line

#define ENABLE_3RDPALT

if you have this option enabled

or

//#define ENABLE_3RDPALT

if you have it disabled.

Now in the config look for :

class Man:Land

In this class , the 3rd person camera position is defined, and it will be used by every classes that inherit from the class Man:Land (meaning every soldiers as none of them redefine that camera, they still use the one defined in class Man:Land )

The interesting lines are there :

#ifndef ENABLE_3RDPALT
	extCameraPosition[]={0,0.3,-3.5};
#endif

and

#ifdef ENABLE_3RDPALT
	extCameraPosition[]={0.25,-0.1,-1.4};
#endif

The 1st part mean that if in the start of the config, the option is disabled :

//#define ENABLE_3RDPALT

( // mean that the game will not read what follows it, so ENABLE_3RDPALT will never be defined)

extCameraPosition[]={0,0.3,-3.5};

that's the original OFP camera

Now if in the start of the option the ENABLE_3RDPALT is defined (there's no // in front of it) , OFP will then consider the 2nd part the one to use, and so

extCameraPosition[]={0.25,-0.1,-1.4};

Share this post


Link to post
Share on other sites

Thanks for sharing and well done Faguss!

Would be best to see this integrated into the BIKI.

Share this post


Link to post
Share on other sites
Thanks Faguss. Are there any detailed examples

that could be included with a description of the

benefits gained by using the PreProcessor?

I won't add any to doc. I encourage readers to paste their own examples here in this topic.

The Bohemia Interactive Community Wiki

also has some OFP specific PreProcessor

reference documentation:

You mean the Arma2 wiki? Not much there comparing to GNU CPP documentation. Only thing I've learned was the include absolute path.

Share this post


Link to post
Share on other sites

Thanks for the example Sanctuary.

The BI Wiki refers to the preprocessFile entry

as being introduced in OFP 1.85.

At the bottom of the page, the "See Also" links

point to the PreProcessor Commands entry

which does not explicitly list a program version

but it is listed under:

Categories: Operation Flashpoint: Editing |
ArmA: Addon Configuration | Scripting Topics

---------- Post added at 12:34 PM ---------- Previous post was at 11:52 AM ----------

I also found the discussion in this old (2006) thread useful

in understanding preprocessing in OFP:

Discussion on editing CPP's and getting your work

from o2 to ofp

http://forums.bistudio.com/showthread.php?t=47147

Share this post


Link to post
Share on other sites

It's not shunning, it's simply that at the time i had a need of those #ifdef #ifndef i had no idea " #else " ever existed for this kind of thing.

Share this post


Link to post
Share on other sites
I also found the discussion in this old (2006) thread useful in understanding preprocessing in OFP

Well, before I released the doc I searched on various forums. There's nothing that I haven't knew already.

It's nice of you foobar that you want to help but searching in BI / OFP related sources is (mostly) a waste of time. That's because users are speculating without doing research.

Edited by Faguss

Share this post


Link to post
Share on other sites

Faguss, thank you so much for this doc! You've opened my eyes to arma advanced addonmaking. It was all complete mystery to me before reading. Now "I see" :)

Share this post


Link to post
Share on other sites

I have updated the document. Check top. Corrected grammar, corrected code examples, added extra info.

Share this post


Link to post
Share on other sites

I have updated doc again - small corrections.

Some time ago I had a discussion with Mikero about preprocessor. In ARMAs it's much different from OFP (less friendly). If you're into ARMA editing don't read this file or you'll learn bad habits.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×