public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* std::strcpy is not a member
@ 2010-02-23 15:47 Vardhan, Sundara (GE Infra, Energy)
  2010-02-23 15:49 ` Andrew Haley
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Vardhan, Sundara (GE Infra, Energy) @ 2010-02-23 15:47 UTC (permalink / raw)
  To: gcc-help

Hi All

Recently compiled gcc 4.4.3 for AIX using the following configure
options :

 --with-as=/usr/bin/as --with-ld=/usr/bin/ld
--enable-languages=c,c++,fortran --prefix=/cots/gnu/gcc443
--enable-threads --enable-version-specific-runtime-libs --disable-nls
--enable-decimal-float=dpd --host=powerpc-ibm-aix5.3.0.0

Successfully installed and compiled my application. I get the following
error on the C++ code compilation :
error: 'strcpy' is not a member of 'std'

The source code does have "using namespace std;"

The same source code does not have an issue with gcc 4.2.3 on AIX.  Am I
missing something when building the new compiler version?

I would very much appreciate if you can give me pointers or solution for
this issue.

Thanks in advance

With Regards

Vardhan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: std::strcpy is not a member
  2010-02-23 15:47 std::strcpy is not a member Vardhan, Sundara (GE Infra, Energy)
@ 2010-02-23 15:49 ` Andrew Haley
  2010-02-23 16:26   ` Vardhan, Sundara (GE Infra, Energy)
  2010-02-23 16:03 ` John (Eljay) Love-Jensen
  2010-02-23 16:07 ` Marc Glisse
  2 siblings, 1 reply; 8+ messages in thread
From: Andrew Haley @ 2010-02-23 15:49 UTC (permalink / raw)
  To: Vardhan, Sundara (GE Infra, Energy); +Cc: gcc-help

On 02/23/2010 03:38 PM, Vardhan, Sundara (GE Infra, Energy) wrote:
> Hi All
> 
> Recently compiled gcc 4.4.3 for AIX using the following configure
> options :
> 
>  --with-as=/usr/bin/as --with-ld=/usr/bin/ld
> --enable-languages=c,c++,fortran --prefix=/cots/gnu/gcc443
> --enable-threads --enable-version-specific-runtime-libs --disable-nls
> --enable-decimal-float=dpd --host=powerpc-ibm-aix5.3.0.0
> 
> Successfully installed and compiled my application. I get the following
> error on the C++ code compilation :
> error: 'strcpy' is not a member of 'std'
> 
> The source code does have "using namespace std;"
> 
> The same source code does not have an issue with gcc 4.2.3 on AIX.  Am I
> missing something when building the new compiler version?
> 
> I would very much appreciate if you can give me pointers or solution for
> this issue.

Send us a test case.

You really should now this by now, you've been posting here long
enough.

Andrew.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: std::strcpy is not a member
  2010-02-23 15:47 std::strcpy is not a member Vardhan, Sundara (GE Infra, Energy)
  2010-02-23 15:49 ` Andrew Haley
@ 2010-02-23 16:03 ` John (Eljay) Love-Jensen
  2010-02-23 16:07 ` Marc Glisse
  2 siblings, 0 replies; 8+ messages in thread
From: John (Eljay) Love-Jensen @ 2010-02-23 16:03 UTC (permalink / raw)
  To: Vardhan, Sundara (GE Infra, Energy), GCC-help

Hi Vardhan,

> Recently compiled gcc 4.4.3 for AIX using the following configure
> options :
> 
>  --with-as=/usr/bin/as --with-ld=/usr/bin/ld
> --enable-languages=c,c++,fortran --prefix=/cots/gnu/gcc443
> --enable-threads --enable-version-specific-runtime-libs --disable-nls
> --enable-decimal-float=dpd --host=powerpc-ibm-aix5.3.0.0
> 
> Successfully installed and compiled my application. I get the following
> error on the C++ code compilation :
> error: 'strcpy' is not a member of 'std'
> 
> The source code does have "using namespace std;"
> 
> The same source code does not have an issue with gcc 4.2.3 on AIX.  Am I
> missing something when building the new compiler version?
> 
> I would very much appreciate if you can give me pointers or solution for
> this issue.

Worked on my machine.

Do you have a small exemplary toy program that exhibits the problem?  To use
as a test case.

Thanks,
--Eljay

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: std::strcpy is not a member
  2010-02-23 15:47 std::strcpy is not a member Vardhan, Sundara (GE Infra, Energy)
  2010-02-23 15:49 ` Andrew Haley
  2010-02-23 16:03 ` John (Eljay) Love-Jensen
@ 2010-02-23 16:07 ` Marc Glisse
  2010-02-23 16:07   ` Vardhan, Sundara (GE Infra, Energy)
  2 siblings, 1 reply; 8+ messages in thread
From: Marc Glisse @ 2010-02-23 16:07 UTC (permalink / raw)
  To: Vardhan, Sundara (GE Infra, Energy); +Cc: gcc-help

On Tue, 23 Feb 2010, Vardhan, Sundara (GE Infra, Energy) wrote:

> Recently compiled gcc 4.4.3 for AIX using the following configure
> options :
>
> --with-as=/usr/bin/as --with-ld=/usr/bin/ld
> --enable-languages=c,c++,fortran --prefix=/cots/gnu/gcc443
> --enable-threads --enable-version-specific-runtime-libs --disable-nls
> --enable-decimal-float=dpd --host=powerpc-ibm-aix5.3.0.0
>
> Successfully installed and compiled my application. I get the following
> error on the C++ code compilation :
> error: 'strcpy' is not a member of 'std'
>
> The source code does have "using namespace std;"

But the source code does not have:
#include <cstring>
which is what you need for std::strcpy.

> The same source code does not have an issue with gcc 4.2.3 on AIX.

Maybe you #include <iostream> and in 4.2 iostream includes cstring in turn 
but a cleanup in libstdc++ means this is not the case anymore?

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: std::strcpy is not a member
  2010-02-23 16:07 ` Marc Glisse
@ 2010-02-23 16:07   ` Vardhan, Sundara (GE Infra, Energy)
  0 siblings, 0 replies; 8+ messages in thread
From: Vardhan, Sundara (GE Infra, Energy) @ 2010-02-23 16:07 UTC (permalink / raw)
  To: gcc-help

Hi Marc

Thanks that was the missing piece. Wonder how the same program compiles
fine in gcc 4.2.3. Perhaps some change that is now required to
explicitly put the header file. 

Thanks a lot

With Regards

Vardhan 

-----Original Message-----
From: Marc Glisse [mailto:marc.glisse@normalesup.org] 
Sent: Tuesday, February 23, 2010 11:03 AM
To: Vardhan, Sundara (GE Infra, Energy)
Cc: gcc-help@gcc.gnu.org
Subject: Re: std::strcpy is not a member

On Tue, 23 Feb 2010, Vardhan, Sundara (GE Infra, Energy) wrote:

> Recently compiled gcc 4.4.3 for AIX using the following configure 
> options :
>
> --with-as=/usr/bin/as --with-ld=/usr/bin/ld 
> --enable-languages=c,c++,fortran --prefix=/cots/gnu/gcc443 
> --enable-threads --enable-version-specific-runtime-libs --disable-nls 
> --enable-decimal-float=dpd --host=powerpc-ibm-aix5.3.0.0
>
> Successfully installed and compiled my application. I get the 
> following error on the C++ code compilation :
> error: 'strcpy' is not a member of 'std'
>
> The source code does have "using namespace std;"

But the source code does not have:
#include <cstring>
which is what you need for std::strcpy.

> The same source code does not have an issue with gcc 4.2.3 on AIX.

Maybe you #include <iostream> and in 4.2 iostream includes cstring in
turn but a cleanup in libstdc++ means this is not the case anymore?

--
Marc Glisse

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: std::strcpy is not a member
  2010-02-23 15:49 ` Andrew Haley
@ 2010-02-23 16:26   ` Vardhan, Sundara (GE Infra, Energy)
  2010-02-23 18:08     ` Kevin P. Fleming
  0 siblings, 1 reply; 8+ messages in thread
From: Vardhan, Sundara (GE Infra, Energy) @ 2010-02-23 16:26 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc-help

Hi Andrew

I apologize for that. Assumed that I would have not built the gcc with
the correct set of configure parameters. Please find below a very simple
test source :

 /*
** Includes
*/
/*START INCLUDE*/
#include <stdio.h>
#include <string.h>


using namespace std;

/* STOP INCLUDE*/

main()
{
 char s[10];

 std::strcpy(s,"NO TAG");
 printf("%s\n",s);

}

Hope this is ok. Thanks much

With Regards

Vardhan

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Andrew Haley
Sent: Tuesday, February 23, 2010 10:47 AM
To: Vardhan, Sundara (GE Infra, Energy)
Cc: gcc-help@gcc.gnu.org
Subject: Re: std::strcpy is not a member

On 02/23/2010 03:38 PM, Vardhan, Sundara (GE Infra, Energy) wrote:
> Hi All
> 
> Recently compiled gcc 4.4.3 for AIX using the following configure 
> options :
> 
>  --with-as=/usr/bin/as --with-ld=/usr/bin/ld 
> --enable-languages=c,c++,fortran --prefix=/cots/gnu/gcc443 
> --enable-threads --enable-version-specific-runtime-libs --disable-nls 
> --enable-decimal-float=dpd --host=powerpc-ibm-aix5.3.0.0
> 
> Successfully installed and compiled my application. I get the 
> following error on the C++ code compilation :
> error: 'strcpy' is not a member of 'std'
> 
> The source code does have "using namespace std;"
> 
> The same source code does not have an issue with gcc 4.2.3 on AIX.  Am

> I missing something when building the new compiler version?
> 
> I would very much appreciate if you can give me pointers or solution 
> for this issue.

Send us a test case.

You really should now this by now, you've been posting here long enough.

Andrew.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: std::strcpy is not a member
  2010-02-23 16:26   ` Vardhan, Sundara (GE Infra, Energy)
@ 2010-02-23 18:08     ` Kevin P. Fleming
  2010-02-23 23:54       ` Marc Glisse
  0 siblings, 1 reply; 8+ messages in thread
From: Kevin P. Fleming @ 2010-02-23 18:08 UTC (permalink / raw)
  To: Vardhan, Sundara (GE Infra, Energy); +Cc: Andrew Haley, gcc-help

Vardhan, Sundara (GE Infra, Energy) wrote:

> I apologize for that. Assumed that I would have not built the gcc with
> the correct set of configure parameters. Please find below a very simple
> test source :
> 
>  /*
> ** Includes
> */
> /*START INCLUDE*/
> #include <stdio.h>
> #include <string.h>

This is not C++, it's C. If you want the C-style string functions
available in the C++ 'std' namespace, you must do:

#include <cstring>

-- 
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: kfleming@digium.com
Check us out at www.digium.com & www.asterisk.org

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: std::strcpy is not a member
  2010-02-23 18:08     ` Kevin P. Fleming
@ 2010-02-23 23:54       ` Marc Glisse
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Glisse @ 2010-02-23 23:54 UTC (permalink / raw)
  To: Kevin P. Fleming; +Cc: Vardhan, Sundara (GE Infra, Energy), gcc-help

On Tue, 23 Feb 2010, Kevin P. Fleming wrote:

> Vardhan, Sundara (GE Infra, Energy) wrote:

>> #include <stdio.h>
>> #include <string.h>
[then use std::strcpy]

> This is not C++, it's C. If you want the C-style string functions
> available in the C++ 'std' namespace, you must do:
>
> #include <cstring>

It is also perfectly valid C++03. Now most compilers never implemented 
this properly, and C++0X validates that behavior, so the code won't be 
valid C++0X. But then, IIRC, C++0X also undeprecates the inclusion of 
string.h, so the OP might as well keep including string.h and use 
strcpy (without std::).

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-02-23 22:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-23 15:47 std::strcpy is not a member Vardhan, Sundara (GE Infra, Energy)
2010-02-23 15:49 ` Andrew Haley
2010-02-23 16:26   ` Vardhan, Sundara (GE Infra, Energy)
2010-02-23 18:08     ` Kevin P. Fleming
2010-02-23 23:54       ` Marc Glisse
2010-02-23 16:03 ` John (Eljay) Love-Jensen
2010-02-23 16:07 ` Marc Glisse
2010-02-23 16:07   ` Vardhan, Sundara (GE Infra, Energy)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).