Frank Heckenbach wrote:
Sven Jauring wrote:
I'm having problem with preprocessor conditionals containing comparisions, eg. "#if X == 4".
..............
First of all: Please post a complete example! You surely have one on your machine, and it's very annoying for me having to fill in the missing parts before I can try the code!
Should this work as I expect?
Yes, and it does on my machine. There was a bug with conditionals on some platforms (fixed meanwhile), but since you didn't specify your platform or GPC version, I can't tell it if that's the problem you're seeing (look for fjf266 in the To-Do list in the GPC manual).
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/ GPC To-Do list, latest features, fixed bugs: http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
Hi again
I'm terribly sorry for having sent an incomplete program listing. I will try my best to keep my listings as complete as possible in the future. :-) We are trying to build a crosscompiler for Pascal to run on PPC with vxWorks. The source code used for the built compiler is gpc-20010201 and gcc-2.95.2. (Because we had some trouble with the runtime libs and vxWorks, we removed everything that seemed unnecessary for our needs.)
Below is a somewhat more complete listing of an example where the conditional testing of defined macros doesn't work for us: ********************* unit macro_tst; interface
#define MACRO 100
procedure macro_test(input : integer );external;
implementation
procedure macro_test(input : integer ); var n1,n2,n3 : integer; begin n1 := MACRO; n2 := 0; n3 := 0;
#if MACRO == 100 n2 := 200; #endif
#ifdef MACRO n3 := 300; #endif
end; end. ********************** After running the program (on our target system running vxWorks) "n1" and "n3" are set to 100 and 300 respectively, but "n2" still having "0" as its value.
(By the way.. I recently posted a cry for help with 16 bit sets and alignment. Thanks to the great help from Frank Heckenbach and a bit of twiddling with some variables - "TSetElement" in p/rts/sets.pas and "set_word_size", "set_alignment" and "set_words_big_endian" in p/util.c - we finally got a pascal compiler that seems to work for us, besides the conditionals problem above.)
Best Regards Sven Jauring