error C2026 – VC compiler limitation and countermeasure

De facto, I am not familiar with VC compiler and do not use it often either. However, it really gives me a little surprise when I have a try, like the limitation on number of ‘else if’ (I could not remember the error code there). Here is an error I recently encountered – C2026 and some good workarounds – wish it help:)

Detailed instruction on MSDN for this error on Visual Studio 2005: http://msdn.microsoft.com/en-us/library/dddywwsc%28v=vs.80%29.aspx

Issue code episode:

char sz[] =
"
imagine a really, really 
long string here
";

Workaround 1 from MSDN:

char sz[] =
"
imagine a really, really "
"long string here
";

Workaround 2 from sprintf/snprintf

char sz[ 50000];
char *ptr = sz;
ptr += sprintf( ptr, "%s", "imaged long string - Part 1");
ptr += sprintf( ptr, "%s", "imaged long string - Part 2");
...

About daveti

Interested in kernel hacking, compilers, machine learning and guitars.
This entry was posted in Programming and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s