Bug 449855

Summary: strcmp et. al. not a member of std?
Product: [Fedora] Fedora Reporter: James Ralston <ralston>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-06-03 22:26:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description James Ralston 2008-06-03 22:06:59 UTC
The following C++ code compiles with no warnings or errors with gcc 3.4 and gcc 4.1:

#include <string>
int main() {
  const char foo[] = "foo";
  const char bar[] = "bar";
  if (std::strcmp(foo, bar) == 0) {
    return 0;
  }
  return 1;
}

However, with gcc gcc-4.3.0-8 (on Fedora 9), compilation dies with the following
error:

$ g++ -Wall -o test test.c 
test.c: In function ‘int main()’:
test.c:8: error: ‘strcmp’ is not a member of ‘std’

I know that using C-style string operations is deprecated in favor of using C++
string operations, but unfortunately, there's still a lot of code floating
around out there that uses them.  How do I get them to work with gcc 4.3?

Comment 1 Jakub Jelinek 2008-06-03 22:26:49 UTC
Just include the correct header.
#include <cstring>
in this case.