A
abracadabra
Hi all. I am working on some string manipulation, and I want the passed
in string pointer to be checked. So I use "assert" to assure that. But
the C compiler of Visual Studio 2005 fails to compile that, if there's
a variable declaration after an assertion in a function(except for the
"main" function).
Here goes the code,
/************************begin of test code**********************/
#include <stdio.h>
#include <assert.h>
char *donothing(char *test)
{
assert(test!=NULL);
int a;
return test;
}
int main()
{
char *str = "abc";
donothing(str);
return 0;
}
/**************************end of test code********************/
The same code can be compiled successfully by GCC. I don't know if this
has been fixed in Service Pack 1 of Visual Studio 2005. And I am
wondering the result of Visual C++ 6.0 and Visual Studio.net 2003.
in string pointer to be checked. So I use "assert" to assure that. But
the C compiler of Visual Studio 2005 fails to compile that, if there's
a variable declaration after an assertion in a function(except for the
"main" function).
Here goes the code,
/************************begin of test code**********************/
#include <stdio.h>
#include <assert.h>
char *donothing(char *test)
{
assert(test!=NULL);
int a;
return test;
}
int main()
{
char *str = "abc";
donothing(str);
return 0;
}
/**************************end of test code********************/
The same code can be compiled successfully by GCC. I don't know if this
has been fixed in Service Pack 1 of Visual Studio 2005. And I am
wondering the result of Visual C++ 6.0 and Visual Studio.net 2003.