{$IFC vs {$IF syntax

I’m porting some older Mac and Free Pascal code. They use
{$IFC XXXX} {$ELSEC} {$ENDC} syntax. Is there a way to get Oxygene to recognize this syntax?

While I’m at it, is there any way to get .p file extensions treated as .pas for Oxygene?

I’ve never seen this syntax before, you have any help references for it?

I’m moving free pascal code. Link:
http://www.freepascal.org/docs-html/prog/progsu30.html
which says: "In MACPAS mode, this directive can be used as an alternative to the $IF directive. It is supported for compatibility with existing Mac OS pascal compilers. "
and some of this code is common across several platforms, including Mac OSX, Classic, iOS and even Windows.

pmfji - I was curious as well, and found this:

http://www.freepascal.org/docs-html/prog/prog.html

In essence the $xxxC directives seem to be 1:1 equivalent to the corresponding $xxx directive, e.g.

$DEFINEC => $DEFINE

The only variations to this rule seem to be where the $xxxC variant employs a slightly different xxx component in the symbol:

$ELIFC => $ELSEIF
$ENDC  => $ENDIF

Do they use the same DEFINE scope to a different one? Do the C versions mix with the non-C ones,nor are they processed independently?

They use the C versions across all platforms. For now, I’ve gotten permission to convert them for my use to the non-C flavors. Though it will have to be dealt with later when we merge the common code. The $ifdef / $ifndef syntax is different in the common code as well. If you manage to add it, great.

Also, just to reiterate the follow-up question I had, is there a way to have it natively recognize .p file extensions as the equivalent of .pas?

what i meant was;

(a)

{$DEFINE A}
{$IFDEFC A}
// does it see A?

(b)

{$IFDEFC A}
{$IFDEF B}
{$ENDIFC} // will this match $IFDEF B or $IFDEFC A?
{$ENDIF}

I don’t have all the tools for all the platforms, but Laz/FPC on (a) sees A. And for (b) this test:

{$DEFINE A}
// {$DEFINE B}

{$IFDEFC A}
{$IFDEF B}
test = a;
{$ENDIFC} // will this match $IFDEF B or $IFDEFC A?
{$ENDIF}

compiles without error. If the {$DEFINE B} is uncommented, it complains about the non-pascal syntax there. So at least Laz/FPC seems agnostic as to whether the C is there or not.

What the Mac Pascal compilers would do, I don’t know.

Is that closer to answering the question you were asking?

I am speculating a little here, but what I interpret from the Lazarus documentation is that the C variant directives are provided for compatibility with Mac Pascal. e.g. / i.e. Mac Pascal uses $IFDEFC and doesn’t support $IFDEF at all. In FPC the ‘C’ versions are simply treated as equivalent to their non-C counterparts and hence can be mixed-in and must then follow the same rules that would apply if either the C or non-C versions had been used exclusively.

I’ve been trying to find any Mac Pascal references that would clear up the question of whether those compilers supported both C and non-C variants and, if they did, what rules applied. But everything in this area currently seems to come from FPC.

So I wonder, do you have to continue to support Mac Pascal in anything other than FPC ?

If not, then the behaviour of a Mac Pascal compiler is moot. FPC is your baseline.

And if FPC treats the C/non-C versions as directly equivalent, and you do not need to maintain compatability with Mac Pascal, then there is no issue caused by simply replacing the C variants with the non-C counterparts, and you can have consistent code in both your FPC and Oxygene environments. Win-Win. :slight_smile:

But there’s a lot of "if"s in there. :slight_smile:

There are folks using the Mac Pascal compilers on the code. But we’ve decided to just work around it.

Now if I could just get Oxygene to recognize .p file extensions as easily as .pas…