View Full Version : Preproccessor Directives

10-13-2003, 12:31 PM
I'm having problems getting preproccessor directives to work, specifically in OnFirstUIBefore() though I haven't tried it elsewhere yet.

I input a directive like MYFIRSTBUILD in the wizard or on the "releases" item under Compiler Preprocessor Defines.

I then write code like this:

MessageBox( "Test", INFORMATION );

but the message box does not come up. Another message box outside of the preproccessor block does get called, so the function is running. #ifdef just dosen't seem to be working. Any ideas?

10-14-2003, 05:31 AM
I don't know, but this is the way I use them:

I include the flags in the "Compiler Preprocessor Defines" of the release like this: APP=1;LEVEL=2;

Then, in the script I use them like this:

#if (APP=1)
svSomeVariable = "Number one";
#elif (APP=2)
svSomeVariable = "Number two";

Hope this helps.

10-14-2003, 11:19 AM
This does not work in my eval copy of DevStudio 9... I've created several test projects, and tried defining constants in both the "setup command line" item in the form: /d MYTESTVAR=1 and in "compiler preprocessor defines" and as MYTESTVAR=1 in the releaseI created under the media...releases item. I've tried using both #ifdef and #if in the forms, and in builds with one or several different releases. I've tried builing it with release, clean release, and through the release wizard, but none of this seems to have any effect. The script compiler simply does not seem to see my preprocessor directives.

MessageBox( "Test", INFORMATION );


MessageBox( "Test", INFORMATION );

I might be doing something incredibly stupid =) but I'm pretty sure I'm doing everything as expected... yet it still never calls into the code wrapped in the preprocessor definitions. What could I possibly be doing incorrectly, differently, or wrongly in this situation? Is there any other caveat as far as how and when preprocessor directives should work? I'm using an installscript project, and my code is placed in the OnFirstUIBefore function, though I've tried the directives elsewhere and they still do not function.


10-14-2003, 06:14 PM

Unfortunately media based preprocessor settings don't work in DevStudio 9.0, the tracking # for this issue is 1-F6IDT.

This is tenatively scheduled to be fixed in the first DevStudio9 SP.

For now the only workaround is to specify the preprocessor settings for the entire project via. Build | Settings.

Devin Ellingson
InstallShield Software Corporation

10-15-2003, 05:33 AM
It works perfectly for me.

I set the defines at Media \ Releases \ Some release \ Compiler Preprocessor Defines.

My code is in the OnBegin function.

I use 9.0 eval.

10-15-2003, 11:08 AM
What's the ETA on the first SP? Is there any way to get a beta fix?

10-15-2003, 04:23 PM

ETA (note that 'E' stands for "Estimate") is November. That's as granular of an estimate that we can provide. It's also, not set in stone.

There won't be a beta for the SP.


10-17-2003, 01:19 PM
Ok, well, if it's gonna be months, what's the best work around to release-dependent alteration of scripted installation behavior, if compiler preprocessor defines can't be used?

10-17-2003, 01:34 PM

As Devin mentioned, project-wide preprocessor flags still work. But, that probably won't help you.

You could try this. (I haven't tested it.)
1. Create a hidden feature for each release that you'll have.
FeatureRel1, FeatureRel2, ...
2. Add a global variable to your script to hold the release type:
INT g_iRelType;
#define RELTYPE_1 1
#define RELTYPE_2 2
3. Early in OnBegin, use FeatureGetData to figure out if the feature is in the project.
4. In the release wizard, select only the appropriate feature for each release.
5. In your script, don't use preprocessor defines, use the variable you created in step1.
if (g_iReltype == 1) then
// do reltype 1 stuff
else (...)

Let us know if it works.


10-20-2003, 11:47 AM
I've implemented it and it works fine; should be a workable band-aid till the service pack, thanks.

11-18-2003, 05:17 PM
>ETA (note that 'E' stands for "Estimate") is November. That's as >granular of an estimate that we can provide. It's also, not set in >stone.
>There won't be a beta for the SP.

Well, especially after that particular condescension, I was hoping this would be fixed in the first service pack. It apparently was not, based on the release notes?

11-18-2003, 06:04 PM

I'm sorry if that sounded condescending. I definitely didn't mean it to be. I just didn't want to be held accountable if we didn't hit the November date.

Anyway, it was definitely fixed in the SP. I'm looking now to determine why it was not listed in the release notes.


11-19-2003, 11:35 AM
I've tested it, and it does in fact work correctly now. Thanks!

04-06-2004, 08:33 AM
Does anyone know for certain, now that DevStrudio 9 SP1 is released, whether 1-F6IDT was indeed fixed in SP1?

I am using SP1, and I find that when I build my project on the command line using the SA builder (IsSaBld.exe), the script compiler ignores the compiler preprocessor defines I've defined for my releases.

I'm pretty confident that I don't have a syntax or usage error: my builds work exactly as expected when I build from the IDE. But when built by the standalone builder on command line, none of my defines are recognized. I've tried alternate declarations, this did not make a difference.

The ability to branch code based on compiler defines is critical to the success of this project. Also critical is building the project with the SA builder.



04-06-2004, 10:01 AM
Hi Art,

That WO was fixed in the SP.


04-06-2004, 10:14 AM

Thanks for the response. Is there somewhere I can get a definition of exactly what was fixed? The SP1 release notes do not include 1-F6IDT.

Regardless, I'm still having difficulty getting the command line builder to recognize compiler preprocessor defines. Is that a different issue than the fix defined by 1-F6IDT?

Or maybe I should ask the question this way: Are compiler preprocessor defines recognized by the stand alone command line builder?



04-06-2004, 10:29 AM
Hi Art,

You would need to use compile.exe and isbuild.exe to do what you want from the command line.

1-F6IDT was that preprocessor defines didn't work when specified in a media (but they did when setting them in Build... settings). I don't think that is your issue. Actually, the fix may help you.

You could configure different releases with different preprocessor defines. Then, from the standalone command line, specify which release you would like to build.


04-06-2004, 10:40 AM
Thanks again. As far as I know, that's exactly what I'm doing.
Example: I've defined (under Media) a release "version_standard". For that release, I have "Compiler Preprocessor defines" set to _VERSION_STANDARD. In script code I do things like this:

function BOOL IsRegistrationLive ()
BOOL bRetVal;
bRetVal = TRUE;
bRetVal = FALSE;
return (bRetVal);

When I build with IDE, it works great. When I build using ths standalone builder, e.g.

\\%COMPUTERNAME%\IS_StandaloneBuilder\IsSaBld.exe -r "version_standard" -c "COMP" -p NameOfMyProjectHere.ism

I find that _VERSION_STANDARD is never defined. I've tried various other usages, nothing seems to work when using the command line. Also see the thread I started here for more details:

It occurs to me that perhaps the command line builder is not SP1! How would I know?
IIRC, I downloaded it from somewhere on the InstallShield site.



04-06-2004, 11:09 AM
Hi Art,

If you did install the 9.0 Standalone build but didn't upgrade it when you upgraded the product to 9.01, that could definitely be the problem.

You can verify the version of your standalone build by looking in the Add Remove Programs of that system. Under "InstallShield DevStudio 9 Standalone Build" click the "Click here for support information" link. It'll tell you the version. It should be 9.01.427.


04-06-2004, 11:24 AM
Well, I verified that my SA builder was definitely out of date. I downloaded and installed the latest (ARP indicates 9.01.427). Now I have a different problem :(

When I run the setups generated by the SA builder I get an error message the likes I've not seen before

Setup has experienced an error
Please do the following
- Close any running programs
- Empty your temporary folder
- Check your internet connection

Then try to run the setup again
Error code -6002

This 6002 couldn't be the Windows API return code ERROR_FILE_ENCRYPTED, could it?

I've done the recommended steps and it didn't help.
Symptoms are identical on a Windows 2000 VM and on my development XP+SP1 box.

Any suggestions?



04-06-2004, 11:32 AM
Hi Art,


Did you go thru this KB?



04-06-2004, 12:21 PM

Thanks once again. I finally have the breakthroughs I needed. (woo-hoo):o

1) Upgrade SA builder to SP1

2) Give the share I created for the SA builder **change permissions**. I had not previously noticed a couple of these in the output of the SA builder:

Compressing \\arthur\is_standalonebuilder\redist\boot files\setup.dll to \\arthur\is_standalonebuilder\redist\boot files\setup.dl_. Can't open output file: \\arthur\is_standalonebuilder\redist\boot files\setup.dll.

Once I allowed write permissions to the share I was getting traction again, my new setup runs when built with the command line and the compiler defines are recognized.

Suggestion: I consider the final output of the builder a false positive:

Build finished at 04/06/04 11:54:57.
version_standard - 0 error(s), 1 warning(s)

In my opinion, "can't open output file" errors should be fatal, flagged as a build error, no setup.exe generated.

The warning is a result of unused functions (I'll take up a different thread on that topic some day!).