1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

char* test = new char[a];

Discussion in 'Embedded' started by bokiteam, Jan 16, 2006.

  1. bokiteam

    bokiteam Guest

    Hi All,
    In our MCU, it didn't support this declaration, it says it is using
    GCC in C89 mode and the C89 standard.

    char* test = new char[a];

    Could you please advice?

    Thank you very much!

    Best regards,
    Boki.
     
    bokiteam, Jan 16, 2006
    #1
    1. Advertisements

  2. bokiteam

    Ico Guest

    Boki,

    This is not valid C. It might be C++, but since I am no C++ programmer I
    can't say that for sure.

    You are probably looking for something like this :

    #include <stdlib.h>

    char *test = malloc(a);
     
    Ico, Jan 16, 2006
    #2
    1. Advertisements

  3. bokiteam

    bokiteam Guest

    Thank you for advice.

    Best regards,
    Boki.
     
    bokiteam, Jan 16, 2006
    #3
  4. bokiteam

    Zara Guest


    If you are in a C89 or C99 standard, the you are compiling C, which
    know of no new operator.

    you should:
    a) either use malloc and free instead of new and delete, and keep on
    programming in C

    b) or change to C++, compiler option -sdt=c++98

    Whichever fits you.

    Best regards,

    Zara
     
    Zara, Jan 16, 2006
    #4
  5. bokiteam

    bokiteam Guest

    Got it, thanks.

    Best regards,
    Boki.
     
    bokiteam, Jan 18, 2006
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.