From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b0ce87e62e62c154,start X-Google-Attributes: gid103376,public From: "Fco Jos� Perera" Subject: "#define" and C2Ada Date: 2000/01/21 Message-ID: #1/1 X-Deja-AN: 575668530 X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 X-Complaints-To: usenet@teleline.es X-Trace: telenews.teleline.es 948452436 194.224.57.120 (Fri, 21 Jan 2000 12:00:36 MET) Organization: Clientes_Teleline NNTP-Posting-Date: Fri, 21 Jan 2000 12:00:36 MET Newsgroups: comp.lang.ada Date: 2000-01-21T00:00:00+00:00 List-Id: I have a problem using the c2ada translator. c2ada needs a definition of each macro definition in the ".py" configuration file (for example as a const int. Always a const or a var). So I can't use this macros for defining array sizes and a warning results. Knows anyone how to define macros and later use these in array definitions in order to pass this code through c2ada and obtain a suitable Ada code ? I've explained this in an example. In my C code I' ve got some definitions like the explained into the following example: ------------------------ #define MAX 10 void main (void){ int t[MAX]; t[0]=1; } ---------------------- I have created a ".py" configuration file defining MAX like the following example ".py" file: ---------------------- ac = the.source("prb.c").macro("MAX") ac.replacement = "const int MAX = 10;" --------------------- The result was an adb as following: --- prb.adb------------------------------------------ with C; with C.Ops; use C.Ops; package body prb is type int_array is array(C.natural_int range <>) of aliased C.int; MAX: aliased C.int := 10; procedure main is t : aliased int_array(0..C.natural_int'Last); begin t(0) := 1; end main; pragma Convention(C, main); pragma Export(C, MAX, "MAX"); end prb; ---------------------------- A message error appears: "Warning: Failed reducing array index to a constant integer value." ---------------------------- If there is not a way to obtain a suitable result for macro and arrays managing, konws anyone how to obtain a result different of the example: The problem is the obtained definition: "MAX: aliased C.int := 10;" Why it's "aliased C.int" and not " constant int ". This involves a problem for me because is difficult to separate constants from the variables in the resultant code. So is not easy to make the necessary changes in order to convert the resultant code into final Ada. Jose Perera