Re: Need help to port VAX code to Alpha and to Itaninum
From: John E. Malmberg (wb8tyw_at_qsl.network)
Date: 03/22/05
- Next message: Larry Kilgallen: "Re: Memory for PWS500a"
- Previous message: bob_at_instantwhip.com: "Re: Word-11 font suddenly stopped working. Now what?"
- In reply to: Laksh: "Need help to port VAX code to Alpha and to Itaninum"
- Next in thread: Ed Vogel: "Re: Need help to port VAX code to Alpha and to Itaninum"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 22 Mar 2005 08:40:21 -0500
Laksh wrote:
> Hi guys,
> I am working on project, which involves porting kind of stuff from VAX
> code Alpha and to Itaninum. Here what I am working project very big and
> vast of codeing files are there. I have compiled with our old vax code
> /stand=relaxed_ansi instead of /stand=vaxc. I hope that What I am doing
> rt :). But thing is while compile with option I got so many warning
> errors like as show below. This is a bit of code
>
> #include <stdio.h>
> int main(){
> unsigned long int GEN_TRANS_LOGICAL(char *, char *);
> char as_logical[] = "DECEDI$AS_PERF";
> char as_text[257] = {0};
> as_logical_status = GEN_TRANS_LOGICAL( &as_logical, &as_text);
> }
>
> 1st case: If I compile with /stand=Vaxc, I didn't get any of warning
> messages.
/VAXC puts the compiler in a mode where it will ignore many critical
errors that past C specifications did not require checks for.
/VAXC should be removed from any program in development that you care
about getting correct answers from.
I would recommend instead to use /WARN=ENABLE=(LEVEL4, QUESTCODE)
Some of the informational diagnostics that this generates can be
ignored, but others will find critical programming errors.
> 2nd case: If I compile with /stand=relaxed_ansi, it came up with lot of
> warning errors like as shown below.
>
> CC
> /OBJ=REFTEST/NOLIST/NODEBUG/NOANA/NOOPTIMIZE=(INLINE=AUTO,LEVEL=4,UNROLL=0)/Incl=DECEDI_SRC:/DEFIN=MEMBER_ALIGN/WARN
> =(NOINF,DISABLE=PROTOSCOPE3,ENABLE=ALIGNMENT)/FLOAT=IEEE reFTEST.C
>
>
> as_logical_status = GEN_TRANS_LOGICAL(&as_logical,&as_text);
> ..............................................^
> %CC-W-PTRMISMATCH, In this statement, the referenced type of the
> pointer value "&as_logical" is "array [7] of char", which is not co
> mpatible with "char".
> at line number 8 in file EDIV43:[WRK]REFTEST.C;11
>
> as_logical_status = GEN_TRANS_LOGICAL(&as_logical,&as_text);
> ..........................................................^
> %CC-W-PTRMISMATCH, In this statement, the referenced type of the
> pointer value "&as_text" is "array [257] of char", which is not com
> patible with "char".
> at line number 8 in file EDIV43:[WRK]REFTEST.C;11
>
> If I remove '&' from the line "as_logical_status = GEN_TRANS_LOGICAL(
> &as_logical, &as_text); ", that error went off.
> Can anybody helps me why is coming like this? How to rectify this
> problem , without changing code in almost in every place around 7000
> places.. Is there any way to rectify this?.
Not really, the original code was wrong, and the compiler was not
diagnosing the problem. It also appears to be a common coding error in
older C programs.
Some of the editors allow you to write macro programs in them so that
you can use those macros to automatically make many similar corrections.
Arrays are passed by address on C. When you explicitly add an & to
them, you are passing the address of the array variable instead of a
pointer to the start of the array.
So you are trying to pass a pointer to a pointer to an array where you
have told the compiler only passing a pointer to the array.
In the case of an array declared the way that you have done the two
above, both values end up the same even though the types do not match.
In other cases though, if you are working with pointer variables, the
resulting value is totally different, and will likely cause data
corruption, as instead of passing the intended array, the usual result
is passing a pointer to the local stack.
> I used Compaq C v6.5 compiler.
> Suggestion will be appriciable at this great moment!!
I would recommend that you use the /WARN=ENABLE=(LEVEL4, QUESTCODE) and
first fix all of the warning messages, and then work on removing all of
the informational messages. There may be some informational messages
that you can not remove and those can be suppressed with #pragma message
disable xxxxxx in the code.
Also start looking at where you can add the "const" modifier to function
declarations and prototypes.
This enables the compiler to better optimize the modules that call those
routines, and such optimizations can be very important to I64 and Alpha
programs. It may also detect some more bugs.
In addition, any variables that are initialized at compile time and
never changed by the program should get a "const" modifier for the same
reasons.
Pointer variables that always point to constant data that is not
modified should also get this modifier.
-John
wb8tyw@qsl.network
Personal Opinion Only
- Next message: Larry Kilgallen: "Re: Memory for PWS500a"
- Previous message: bob_at_instantwhip.com: "Re: Word-11 font suddenly stopped working. Now what?"
- In reply to: Laksh: "Need help to port VAX code to Alpha and to Itaninum"
- Next in thread: Ed Vogel: "Re: Need help to port VAX code to Alpha and to Itaninum"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|