Bug 449855 - strcmp et. al. not a member of std?
strcmp et. al. not a member of std?
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
9
All Linux
low Severity low
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-06-03 18:06 EDT by James Ralston
Modified: 2008-06-03 18:26 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-06-03 18:26:49 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description James Ralston 2008-06-03 18:06:59 EDT
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 18:26:49 EDT
Just include the correct header.
#include <cstring>
in this case.

Note You need to log in before you can comment on or make changes to this bug.