Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > mem.h doesn't seem to be available in g++

Reply
Thread Tools

mem.h doesn't seem to be available in g++

 
 
Simon Elliott
Guest
Posts: n/a
 
      06-27-2005
I have some C code in a header which must be #included in both C and
C++ source files. The code in the header makes use of memcpy().

In bcb3 and bcb6, memcpy() needs <mem.h>. According to the g++ man page
for memcpy(), memcpy() needs <string.h>, and g++ complains that it
can't find <mem.h>

Is there anything in the standards which specify which header memcpy()
should require?

I'm aware of <cstring> but can't use it because this code must be both
valid C and C++

I don't want to end up with code which is stuffed full of #ifdef's for
all the different compilers I need to support. How do I deal with this
issue?

--
Simon Elliott http://www.ctsn.co.uk
 
Reply With Quote
 
 
 
 
Pete Becker
Guest
Posts: n/a
 
      06-27-2005
Simon Elliott wrote:
>
> Is there anything in the standards which specify which header memcpy()
> should require?
>
> I'm aware of <cstring> but can't use it because this code must be both
> valid C and C++
>


It's declared in <string.h> and <cstring>.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      06-27-2005
Simon Elliott wrote:
> I have some C code in a header which must be #included in both C and
> C++ source files. The code in the header makes use of memcpy().
>
> In bcb3 and bcb6, memcpy() needs <mem.h>. According to the g++ man page
> for memcpy(), memcpy() needs <string.h>, and g++ complains that it
> can't find <mem.h>
>
> Is there anything in the standards which specify which header memcpy()
> should require?


Yes. 'memcpy' is available either in <cstring> or <string.h>. The former
is supposed to have it in 'std' namespace. The latter is supposed to have
it in both global and 'std' namespaces.

>
> I'm aware of <cstring> but can't use it because this code must be both
> valid C and C++


Use <string.h> then.

>
> I don't want to end up with code which is stuffed full of #ifdef's for
> all the different compilers I need to support. How do I deal with this
> issue?
>


Try to always use the common standard denominator. Be prepared though
to still have some #ifdef's in your code. It's inevitable. Not all
compilers support 100% of the language and quite a few simply have bugs.

V
 
Reply With Quote
 
Maxim Yegorushkin
Guest
Posts: n/a
 
      06-28-2005
On Tue, 28 Jun 2005 00:07:17 +0400, Simon Elliott <Simon at <ctsn.co.uk>>
wrote:

> I have some C code in a header which must be #included in both C and
> C++ source files. The code in the header makes use of memcpy().
>
> In bcb3 and bcb6, memcpy() needs <mem.h>. According to the g++ man page
> for memcpy(), memcpy() needs <string.h>, and g++ complains that it
> can't find <mem.h>


There is no standard header <mem.h>. C standard ISO/IEC 9899:1999 (E) in
7.21 states memcpy() is declared in <string.h>.

--
Maxim Yegorushkin
 
Reply With Quote
 
Simon Elliott
Guest
Posts: n/a
 
      06-28-2005
On 28/06/2005, Maxim Yegorushkin wrote:

> > In bcb3 and bcb6, memcpy() needs <mem.h>. According to the g++ man
> > page for memcpy(), memcpy() needs <string.h>, and g++ complains
> > that it can't find <mem.h>


> There is no standard header <mem.h>. C standard ISO/IEC 9899:1999 (E)
> in 7.21 states memcpy() is declared in <string.h>.


Thanks for this. It turns out that memcpy() is declared in <string.h>
as well as <mem.h> in the Borland compilers, so I can simply change all
occurances of <mem.h> to <string.h> and have standard and portable code
with no #ifdefs.

--
Simon Elliott http://www.ctsn.co.uk
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
libmsi.a import library from wine, and header files available(entirely free software),available for python-win32 builds under msys+wine Luke Kenneth Casson Leighton Python 0 01-18-2009 08:46 PM
How to find the total and free memory available in RAM. and used & free space available in each disk? kathirvel.com@gmail.com Java 1 11-02-2006 02:31 PM
router doesn't seem to work =?Utf-8?B?ZA==?= Wireless Networking 2 06-12-2005 06:45 PM
RE: Web page is not available - "The Web page you requested is not available offline. To view this page, click Connect" =?Utf-8?B?VHJldm9yIEJlbmVkaWN0IFI=?= ASP .Net 0 06-07-2004 07:11 AM
Re: Web page is not available - "The Web page you requested is not available offline. To view this page, click Connect" Natty Gur ASP .Net 0 06-06-2004 05:46 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57