strdup error on g++ with c++0x

前端 未结 4 1208
情书的邮戳
情书的邮戳 2020-12-17 00:25

I have some C++0x code. I was able to reproduce it below. The code below works fine without -std=c++0x however i need it for my real code.

How do i incl

4条回答
  •  庸人自扰
    2020-12-17 00:42

    This page explains that strdup is conforming, among others, to the POSIX and BSD standards, and that GNU extensions implement it. Maybe if you compile your code with "-D_GNU_SOURCE" it works?

    EDIT: just to expand a bit, you probably do not need anything else than including cstring on a POSIX system. But you are using GCC on Windows, which is not POSIX, so you need the extra definition to enable strdup.

提交回复
热议问题