PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Warning by strcpy at compilation...

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
M-Vetter



Joined: 08 May 2006
Posts: 3

PostPosted: Mon May 08, 2006 7:34 am    Post subject: Warning by strcpy at compilation... Reply with quote

Hi,

As we have changed our compiler, I get this warning in a program that I did not write my self.

As Im not so used to pointers, Im now somewhat unsure what to do as next.

This is how the program structure for the actual variable looks like:

In main program I call the sub-routine like this:

the variable suffix is defined in the main program as:
sting suffix

/* reading coordinates from file COORDINATES.ini */

coordinates_init(init,&Ibegin,&Iend,&Jbegin,&Jend,&I3d,&J3d,&I2d,&J2d,&Ifine,&Jfine,&suffix)

the subroutine is defined like this:

int coordinates_init(file init,int *Ibegin,int *Iend,int *Jbegin,int
*Jend, int *I3d,int *J3d,int *I2d,int *J2d, int *Ifine,int *Jfine,string* suf)
...

local definitions
char suffix[5];

gets input from default in (keyboard):

printf("\n\t Input the number of the submap: ");
scanf("%s",suffix);

copying suffix to suf
/* SUFFIX */

strcpy(suf,suffix);



Here I get the following line from the pgcc compiler,

pgcc -O -I/Net/Groups/BSY/BSY_1/mvetter/gridbgc/include -c -o
coordinates_init.o coordinates_init.c
PGC-W-0095-Type cast required for this conversion (coordinates_init.c:
150)
PGC/x86-64 Linux/x86-64 6.1-4: compilation completed with warnings

Im not so familier with ponters, do you have a suggestion how to avoid
this warning?
The program is running with this warning, but I would be happier if I
knew how the code should be.

Many thanks in advance
Mona
Back to top
View user's profile
Christopher Hulbert



Joined: 01 Dec 2005
Posts: 76

PostPosted: Mon May 08, 2006 8:18 am    Post subject: Reply with quote

The warning is from the src buffer of strcpy being defined as a const char * and you passing in a char *. You're ok ignoring this warning, but if you want to get rid of it, use

strcpy(suf,(const char *)suffix);
Back to top
View user's profile
M-Vetter



Joined: 08 May 2006
Posts: 3

PostPosted: Mon May 08, 2006 11:02 pm    Post subject: Reply with quote

Christopher Hulbert wrote:
The warning is from the src buffer of strcpy being defined as a const char * and you passing in a char *. You're ok ignoring this warning, but if you want to get rid of it, use

strcpy(suf,(const char *)suffix);


Thanks alot!
Back to top
View user's profile
M-Vetter



Joined: 08 May 2006
Posts: 3

PostPosted: Mon May 08, 2006 11:24 pm    Post subject: Reply with quote

Christopher Hulbert wrote:
The warning is from the src buffer of strcpy being defined as a const char * and you passing in a char *. You're ok ignoring this warning, but if you want to get rid of it, use

strcpy(suf,(const char *)suffix);


For some reason it still gives the same warning message!
Back to top
View user's profile
Christopher Hulbert



Joined: 01 Dec 2005
Posts: 76

PostPosted: Tue May 09, 2006 5:09 am    Post subject: Reply with quote

Then it must be from the return value. Try:

(void)strcpy(suf,(const char *)suffix)
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group