473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Including <string.h> fails if <cstring> included

On one particular compiler, this program fails to compile because
memset is an undeclared symbol (it's in namespace std but not in
the global namespace):

#include <cstring>
#include <string.h>

int main()
{
char a[10];
memset(&a, '\0', 10);
return 0;
}

But if the first line is removed then the program compiles.
Apparently what is happening is that the include guards activated
by <cstringmean that the second include is ignored.

Should this be considered a compiler bug?

Nov 20 '06 #1
7 2296
"Old Wolf" <ol*****@inspire.net.nzwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
On one particular compiler, this program fails to compile because
memset is an undeclared symbol (it's in namespace std but not in
the global namespace):

#include <cstring>
#include <string.h>

int main()
{
char a[10];
memset(&a, '\0', 10);
return 0;
}

But if the first line is removed then the program compiles.
Apparently what is happening is that the include guards activated
by <cstringmean that the second include is ignored.

Should this be considered a compiler bug?
I wouldn't think so. I think it would be more a programmer error to include
both Cxxxx and xxxx.h
Nov 20 '06 #2

Old Wolf wrote:
On one particular compiler, this program fails to compile because
memset is an undeclared symbol (it's in namespace std but not in
the global namespace):

#include <cstring>
#include <string.h>

int main()
{
char a[10];
memset(&a, '\0', 10);
return 0;
}

But if the first line is removed then the program compiles.
Apparently what is happening is that the include guards activated
by <cstringmean that the second include is ignored.

Should this be considered a compiler bug?
cstring includes and will call string.h if syntax or compile errors
popped up

Nov 20 '06 #3

Old Wolf ha escrito:
On one particular compiler, this program fails to compile because
memset is an undeclared symbol (it's in namespace std but not in
the global namespace):

#include <cstring>
#include <string.h>

int main()
{
char a[10];
memset(&a, '\0', 10);
return 0;
}

But if the first line is removed then the program compiles.
Apparently what is happening is that the include guards activated
by <cstringmean that the second include is ignored.

Should this be considered a compiler bug?
It's a commpiler bug, you shold read document ?

Davio C. Doug

Nov 20 '06 #4

Old Wolf ha escrito:
On one particular compiler, this program fails to compile because
memset is an undeclared symbol (it's in namespace std but not in
the global namespace):

#include <cstring>
#include <string.h>

int main()
{
char a[10];
memset(&a, '\0', 10);
return 0;
}

But if the first line is removed then the program compiles.
Apparently what is happening is that the include guards activated
by <cstringmean that the second include is ignored.

Should this be considered a compiler bug?
It's a commpiler bug, you shold read document ?

Davio C. Doug

Nov 20 '06 #5

Moli King wrote:
Old Wolf ha escrito:
On one particular compiler, this program fails to compile because
memset is an undeclared symbol (it's in namespace std but not in
the global namespace):

#include <cstring>
#include <string.h>

int main()
{
char a[10];
memset(&a, '\0', 10);
return 0;
}

But if the first line is removed then the program compiles.
Apparently what is happening is that the include guards activated
by <cstringmean that the second include is ignored.

Should this be considered a compiler bug?

It's a commpiler bug, you shold read document ?

Davio C. Doug
that's posibly a good "guess" but at least good compiler doesnot give
priority to which header shoud be read first, header knows which to
include and to exclude

Nov 20 '06 #6

Jim Langston wrote:
"Old Wolf" <ol*****@inspire.net.nzwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
On one particular compiler, this program fails to compile because
memset is an undeclared symbol (it's in namespace std but not in
the global namespace):

#include <cstring>
#include <string.h>

int main()
{
char a[10];
memset(&a, '\0', 10);
return 0;
}

But if the first line is removed then the program compiles.
Apparently what is happening is that the include guards activated
by <cstringmean that the second include is ignored.

Should this be considered a compiler bug?

I wouldn't think so. I think it would be more a programmer error to include
both Cxxxx and xxxx.h

I find that including both files is a baad haabit of coders. but why
compiler error ?
it must be a compiler bug instead :-p

Nov 20 '06 #7
Jim Langston wrote:
"Old Wolf" <ol*****@inspire.net.nzwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
>On one particular compiler, this program fails to compile because
memset is an undeclared symbol (it's in namespace std but not in
the global namespace):

#include <cstring>
#include <string.h>

int main()
{
char a[10];
memset(&a, '\0', 10);
return 0;
}

But if the first line is removed then the program compiles.
Apparently what is happening is that the include guards activated
by <cstringmean that the second include is ignored.

Should this be considered a compiler bug?

I wouldn't think so.
I would: where in the standard do you find the permission that one header
may hide the contents of another header?
I think it would be more a programmer error to
include both Cxxxx and xxxx.h
True but irrelevant for assesing whether the compiler is compliant.
Best

Kai-Uwe Bux
Nov 20 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John Tiger | last post by:
Can anybody have idea about the difference between #include <iostream.h> and #include <iostream>. Is later one valid statement on any compiler. I tried compiling on MSVC second statement give...
5
by: Danny Anderson | last post by:
Hola! I am working on a program where I am including a library that came with my numerical methods textbook. The "util.h" simply includes a large number of files. I had to change the util.h...
1
by: Matt Garman | last post by:
What is the "best" way to copy a vector of strings to an array of character strings? By "best", I mean most elegantly/tersely written, but without any sacrifice in performance. I'm writing an...
11
by: Charles L | last post by:
I have read that the inclusion of <fstream.h> makes the inclusion of <iostream.h> unnecessary. Is this correct? Charles L
1
by: Macca | last post by:
Hi, I have been using <fstream.h> in stdafx.h,(i'm using MFC) to output to text files. I have now started to use vectors and when i added #include <vector> using namespace std; to...
3
by: howachen | last post by:
from many books said, to use strlen(), you need to include <cstringor <string.h>, but i found the following program work, why? #include <iostream> using namespace std; int main() { char...
5
by: Randeh | last post by:
Short story: in a beginning C++ class in college, was in a car accident that caused central spinal stenosis, some new Schmorl's nodes, disc problems and an incredible amount of pain. So far I've...
5
by: Peithon | last post by:
Hi, I'm trying to create a vector of strings and print the contents using an iterator but I'm getting an error with my very first string. Can anyone help?
8
by: Carmen Sei | last post by:
it seem to me that when doing include - #include <string.h- is CRT #inlcude <string- is C++ standard library Is that true those header with .h extension is CRT and those without extension...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.