11 years, 9 months ago.

Compiler error 18 when including <vector>

Hello,

I was trying to include the C++ vector class, but I'm always getting the same error when compiling:

Error: Expected a ")" in "opt/RVDS4.1-r791/include/limits", Line: 553, Col: 2 (Compiler error no. 18)

I tried with a short program but I still get the same error. Is anything wrong with the code to include the library?

#include "mbed.h"
#include <vector>

Serial pc(USBTX, USBRX);                        // creates USB serial port @ 9600 bd

int main()
{
    pc.baud(115200);                            // set baudrate to 115200 
    
    vector<int> ints;                           // vector of ints
    
    ints.push_back(1);
    ints.push_back(2);
    ints.push_back(3);
    
    for(int i=0; i<ints.size(); i++)
        pc.printf("%d\n", ints[i]);
        
           
    while(1)
    {
       // do nothing
    }
}

1 Answer

11 years, 9 months ago.

I copy pasted that code into the online compiler and it compiles fine for me for the LPC1768 (besides the quite high memory consumption of the vector lib).

Are you ure this is the issue, and you don't have another library in your project? Or are you using an offline compiler? (Your error message seems kinda weird).

Indeed. I made a complete new program and now it is compiling fine (for LPC1768 with online compiler). So it is most probably, like you mention, another library that may cause the error. Although without including the <vector> it compiles fine. I will check the other libraries that I'm using.

posted by Gunther Decoster 22 Dec 2013