1. ver 4.0 source question

What is the difference meaning between these two conditions ?

  • #if XXXX
  • #if define(XXXX)

What would be the equivalent for this in the above notation ?

  • #ifndef XXXX
  • ???????????
new topic     » topic index » view message » categorize

2. Re: ver 4.0 source question

Lnettnay said...

What is the difference meaning between these two conditions ?

  • #if XXXX
  • #if define(XXXX)

What would be the equivalent for this in the above notation ?

  • #ifndef XXXX
  • ???????????

I don't 100% understand the question.

with define XXXX 
if !XXXX then 
 
is how it is used. 
exwc -D XXX some.exw 
also works 
 
if not XXXX then 

is not currently supported, but was added as a casual feature request

new topic     » goto parent     » topic index » view message » categorize

3. Re: ver 4.0 source question

ne1uno said...
Lnettnay said...

What is the difference meaning between these two conditions ?

  • #if XXXX
  • #if define(XXXX)

What would be the equivalent for this in the above notation ?

  • #ifndef XXXX
  • ???????????

I don't 100% understand the question.

with define XXXX 
if !XXXX then 
 
is how it is used. 
exwc -D XXX some.exw 
also works 
 
if not XXXX then 

is not currently supported, but was added as a casual feature request

NOTE I talking about the POUND SIGN conditionals.

new topic     » goto parent     » topic index » view message » categorize

4. Re: ver 4.0 source question

Lnettnay said...

What is the difference meaning between these two conditions ?

  • #if XXXX
  • #if define(XXXX)

What would be the equivalent for this in the above notation ?

  • #ifndef XXXX
  • ???????????

let me try that again,

with define XXXZ -- exwc -D XXXZ some.exw also works 
 
ifdef !XXXX then  
 printf(1, " XXXX not defined or other than TRUE", {}) 
elsifdef XXXZ then 
 printf(1, "XXXZ is defined TRUE", {}) 
elsedef 
 printf(1, "XXXX not defined or is TRUE", {}) 
end ifdef 
 

test first then post. maybe XXXZ can't happen but you get the idea. with define XXXX=20 doesn't error but seemingly doesn't exactly work

new question: do any constant expressions work in ifdef?

new topic     » goto parent     » topic index » view message » categorize

5. Re: ver 4.0 source question

Lnettnay said...

What is the difference meaning between these two conditions ?

  • #if XXXX
  • #if define(XXXX)

That looks like C programming language syntax and I don't think there is a difference. They both cause the compiler to check if 'XXXX' has been defined. I assume you know that Euphoria has a different syntax for this concept.

ifdef XXXX then  
   . . . 
end ifdef 
Lnettnay said...

What would be the equivalent for this in the above notation ?

  • #ifndef XXXX
  • ???????????

Are you asking what is the C notation for this or the Euphoria notation? In Euphoria one would write ...

ifdef !XXXX then 
  . . .  
end ifdef 
new topic     » goto parent     » topic index » view message » categorize

6. Re: ver 4.0 source question

ne1uno said...

with define XXXX=20 doesn't error but seemingly doesn't exactly work

new question: do any constant expressions work in ifdef?

I think that "with define XXXX=20" should error, because the concept in Euphoria is that either something is defined or it is not. We are not supposed to be able to assign a specific value to these 'words'. Maybe this is in preparation for a feature later on in v4.1?

new topic     » goto parent     » topic index » view message » categorize

7. Re: ver 4.0 source question

I assume you're asking about the C code.

Lnettnay said...

What is the difference meaning between these two conditions ?

  • #if XXXX
  • #if define(XXXX)

The first instance requires the the macro be both defined, and evaluate to something other than 0.

Lnettnay said...

What would be the equivalent for this in the above notation ?

  • #ifndef XXXX
  • ???????????

I think the best analog would be:

  #if !XXXX 
This requires the macro to evaluate to 0.

Matt

new topic     » goto parent     » topic index » view message » categorize

8. Re: ver 4.0 source question

DerekParnell said...
Lnettnay said...

What is the difference meaning between these two conditions ?

  • #if XXXX
  • #if define(XXXX)

That looks like C programming language syntax and I don't think there is a difference. They both cause the compiler to check if 'XXXX' has been defined. I assume you know that Euphoria has a different syntax for this concept.

ifdef XXXX then  
   . . . 
end ifdef 
Lnettnay said...

What would be the equivalent for this in the above notation ?

  • #ifndef XXXX
  • ???????????

Are you asking what is the C notation for this or the Euphoria notation? In Euphoria one would write ...

ifdef !XXXX then 
  . . .  
end ifdef 

Hi Derek:

Yes I'am talking the "C" notation in the source code.

What is confusing me is that different developers are using different forms of the conditional notation.

Are we sure that this is supported on any compiler. I kind of thought that #if, #ifndef and etc. is generic but I'am not sure where the #if define(XXXX) is coming from. I can't find any information in the Watcom hlp files about it. I'am trying to understand the logic for the compiler when using it for WIN98 because the conditionals don't make sense to me.

Bernie

new topic     » goto parent     » topic index » view message » categorize

9. Re: ver 4.0 source question

bernie said...

Are we sure that this is supported on any compiler. I kind of thought that #if, #ifndef and etc. is generic but I'am not sure where the #if define(XXXX) is coming from.

define() should be defined() is it messpelled in the source somewhere? could be a latent bug.

ex:

#if !defined(__WATCOMC__) && (WINVER > 0x0400) 
  
#endif 

new topic     » goto parent     » topic index » view message » categorize

10. Re: ver 4.0 source question

ne1uno said...
bernie said...

Are we sure that this is supported on any compiler. I kind of thought that #if, #ifndef and etc. is generic but I'am not sure where the #if define(XXXX) is coming from.

define() should be defined() is it messpelled in the source somewhere? could be a latent bug.

ex:

#if !defined(__WATCOMC__) && (WINVER > 0x0400) 
  
#endif 

No I miss spelled it in my Post.

new topic     » goto parent     » topic index » view message » categorize

11. Re: ver 4.0 source question

bernie said...

Yes I'am talking the "C" notation in the source code.

What is confusing me is that different developers are using different forms of the conditional notation.

Are we sure that this is supported on any compiler. I kind of thought that #if, #ifndef and etc. is generic but I'am not sure where the #if define(XXXX) is coming from. I can't find any information in the Watcom hlp files about it. I'am trying to understand the logic for the compiler when using it for WIN98 because the conditionals don't make sense to me.

These are part of the C99 Standard (warning: PDF). In particular, take a look starting at page 148 (160 in my PDF viewer).

ifdef is useful for a simple guard, but the defined syntax is useful for more complex conditions:

#if defined( GUI ) && USE_GTK 

Matt

new topic     » goto parent     » topic index » view message » categorize

12. Re: ver 4.0 source question

mattlewis said...

I assume you're asking about the C code.

bernie said...

What is the difference meaning between these two conditions ?

  • #if XXXX
  • #if define(XXXX)

The first instance requires the the macro be both defined, and evaluate to something other than 0.

bernie said...

What would be the equivalent for this in the above notation ?

  • #ifndef XXXX
  • ???????????

I think the best analog would be:

  #if !XXXX 
This requires the macro to evaluate to 0.

Matt

Thanks Matt and etal that is what I needed to know.

PS: Matt: If you do a check-in of any SVN source after ver 1991.
This is where the compile fails; maybe a file is missing.

---------------------------------------------------------  
        mkdir dosbkobj\back 
        wmake -f makefile.wat .\intobj\main-.c EX="c:\eu1\bin"\exwc.exe EU_TARGE 
T=int. OBJDIR=intobj DEBUG= MANAGED_MEM=1 
Open Watcom Make Version 1.6 
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved. 
Source code is available under the Sybase Open Watcom Public License. 
See http://www.openwatcom.org/ for details. 
        c:\eu1\bin\exwc.exe -i ..\include revget.ex 
        cd .\intobj 
        del *.c 
Could Not Find C:\1205\source\intobj\*.c 
Error(E42): Last command making (.\intobj\main-.c) returned a bad status 
Error(E02): Make execution terminated 
Error(E42): Last command making (interpreter) returned a bad status 
Error(E02): Make execution terminated 
Error(E42): Last command making (winall) returned a bad status 
Error(E02): Make execution terminated 
Error(E42): Last command making (all) returned a bad status 
Error(E02): Make execution terminated 
--------------------------------------------------------------------- 
new topic     » goto parent     » topic index » view message » categorize

13. Re: ver 4.0 source question

bernie said...

PS: Matt: If you do a check-in of any SVN source after ver 1991.
This is where the compile fails; maybe a file is missing.

        del *.c 

The problem is that apparently the del command returns a bad status if it couldn't find anything to delete. Which causes the make process to stop. Try adding a '-' in front of the del command:

   -del *.c 
That tells wmake to ignore non-zero exit codes. When I get to a windows machine, I'll test it and commit the change (unless someone else beats me to it).

Matt

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu