Menu

Problem with new operator

2007-01-25
2012-09-26
  • Nobody/Anonymous

    Hi all:

    In my endless transition to GNU gcc I'm having troubles with the new operator when try to use in the non-throw versio (I.E. the old style of controlling the fault). For example, when I try

    include <new>

    char* cptr = new (std::nothrow) char[10];

    I got some error (whose not appear in BC++): ..."std::nothrow' is not a type"

    Could someone point out where is my error?

    By the way I'm using Dev-C++ 4.9.9.2

    Thanks in advance

    Newbie

     
    • Soma

      Soma - 2007-01-25

      O_o

      There is nothing wrong with the posted line. I'm guessing you misspelled it in your code and transposed it in the post.

      If that isn't the problem, copy and paste the big three. Do not transpose anything.

      Soma

      include <new>

      int main(int argc, char ** argv)
      {
      char * p(new (std::nothrow) char[10]);
      return(0);
      }

       
      • Nobody/Anonymous

        Soma:

        Thank you very much for your's help.

        Although the code was absolutely without mistakes, your observation make me watch in that direction. Possibly I reused an previous C project to my tests, so although the file name where main.cpp, there where a flag IsCpp=0 instead IsCpp=1 in the .dev file. So, make was thinking that is was a C projec (I believe).

        After the appropriate changes, the source compiles seamless.

        Greetings.

        Newbie.

         
  • Haroon Kassim

    Haroon Kassim - 2010-01-25

    Replace #include<new> with #include<iostream>.
    Anyway, what is <new>? </new></iostream></new>

     
  • cpns

    cpns - 2010-01-25

    2010-01-25 04:30:02 GMT
    Replace #include<new> with #include<iostream>.
    Anyway, what is <new>?

    If you don't know, look it up before posting in ignorance. <new> is the
    standard library header that defines std::nothrow.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.