paulftw / hiberlite

C++ ORM for SQLite
BSD 3-Clause "New" or "Revised" License
714 stars 118 forks source link

constant expression in toSQLiteValue(const char* val) #2

Closed d-led closed 11 years ago

d-led commented 11 years ago

First, I like your library! :)

The second line in:

int n=strlen(val);
char s[4+2*n];

is invalid though, as n is not a constant expression. You could do:

char* s=new char[4+2*n];
...
delete[] s;

that will work in all compilers. I've noticed it when compiling with Visual Studio.

paulftw commented 11 years ago

First, thanks!

Back in the day I made a conscious choice of ignoring MSFT crap. But judging from the feedback I got it seems like everyone else in the world is using hiberlite in Visual Studio.

So I should probably listen to my users - there are not that many of them :)

Will try to fix this once I find some time. In the meantime - are you able to test if suggested approach works in GCC? Extra cleanup feels annoying but not too bad.

d-led commented 11 years ago

You're welcome :).

It should work in gcc, but I'll test. Compilers never "win" for long. Today one should consider clang too. The error messages are especially neat.

paulftw commented 11 years ago

I guess this is now fixed?