Server Help

ASSS Questions - Compiling a module in MSVC

Hakaku - Wed Jan 19, 2011 11:23 am
Post subject: Compiling a module in MSVC
So I decided to try compiling a simple module in Microsoft Visual C++ for the fun of it, but while I have everything configured to compile in C and setup similarly as it should in Dev-C++ or Eclipse, I can't seem to get past the following errors and warnings:

Code: Show/Hide

1>------ Rebuild All started: Project: my-module, Configuration: Debug Win32 ------
1>  util.c
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(125): warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\string.h(238) : see declaration of 'strdup'
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(153): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\string.h(188) : see declaration of 'strncpy'
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(212): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(231): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\string.h(110) : see declaration of 'strcat'
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(233): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\string.h(110) : see declaration of 'strcat'
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(476): error C2059: syntax error : 'type'
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(481): error C2059: syntax error : 'type'
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(1158): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(1160): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(1288): warning C4133: 'function' : incompatible types - from 'const char *' to 'LPCWSTR'
1>  my-module.c
1>  Generating Code...
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


I can add '_CRT_SECURE_NO_WARNINGS' into the preprocessor definitions, but I'm still left with:
Code: Show/Hide
1>------ Rebuild All started: Project: my-module, Configuration: Debug Win32 ------
1>  util.c
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(125): warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\string.h(238) : see declaration of 'strdup'
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(476): error C2059: syntax error : 'type'
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(481): error C2059: syntax error : 'type'
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(1158): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(1160): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\my-username\documents\visual studio 2010\projects\my-module\my-module\util.c(1288): warning C4133: 'function' : incompatible types - from 'const char *' to 'LPCWSTR'
1>  my-module.c
1>  Generating Code...
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


Any ideas on how I can resolve this?
JoWie - Wed Jan 19, 2011 12:01 pm
Post subject:
I do not know which version of util.c you have, so this is a guess.
However last time I tried compiling an asss module with VS I had the issue that VS has no C99 support. Such as variable declarations intermingled with code.
Arnk Kilo Dylie - Wed Jan 19, 2011 12:01 pm
Post subject:
...is that util.c YOUR util.c? That doesn't look like asss's, judging by the complete lack of anything similar around those line numbers.
Hakaku - Wed Jan 19, 2011 4:03 pm
Post subject:
Arnk Kilo Dylie wrote:
...is that util.c YOUR util.c? That doesn't look like asss's, judging by the complete lack of anything similar around those line numbers.

No, it's the same file as in /src/main/, I just duplicated the file, a habit I picked up from working with Eclipse. If I include it directly from asss' source directory the problems are still the same, just change the path names.
Dr Brain - Wed Jan 19, 2011 4:08 pm
Post subject:
Care to tell us the version you're using, or better yet, share the offending lines? Only the errors seem relevant. The warnings look harmless.
JoWie - Wed Jan 19, 2011 4:26 pm
Post subject:
And remember that MSVC differs when it comes to the standard library in ways that can break stuff if you assume a particular way of operation.

for example
Code: Show/Hide

char buf[4];
snprintf(buf, 4, "Abcd");

Results in {'A','b','c',0} in GCC and {'A','b','c','d'} in MSVC.
Samapico - Wed Jan 19, 2011 5:04 pm
Post subject:
Is this why it suggests snprintf_s ? Would that function set the last char to 0?
Hakaku - Wed Jan 19, 2011 5:27 pm
Post subject:
I'm using asss 1.4.4 (sorry, I forgot to mention that in my last post), and the lines where the two errors (error C2059: syntax error : 'type') occur are the following:

Quote:
Link * LLGetHead(LinkedList *lst)
{
return lst->start;
}

int LLIsEmpty(LinkedList *lst)
{
return lst->start == NULL;
}


(Lines 476 & 481 in 1.4.4, or 468 & 473 in 1.5.0rc2)
Dr Brain - Wed Jan 19, 2011 6:19 pm
Post subject:
I don't see anything on those lines that could cause an error like that (and not cause an error in a hundred other places).
Arnk Kilo Dylie - Wed Jan 19, 2011 6:23 pm
Post subject:
What's the function above it, and where's the typedef for Link? The answers probably lie there.
Samapico - Sun Jan 30, 2011 11:46 am
Post subject:
I sometimes get the same error on Eclipse, by the way.

One of my module also started giving a 'multiple definitions of...' for EVERY function in util.c, unless I #include "util.c" in my <module>.c file. And if I do include it, I get errors at LLGetHead and LLIsEmpty, just like Hakaku.
Dr Brain - Sun Jan 30, 2011 12:52 pm
Post subject:
You should never #include a .c file, regardless of circumstances, in asss or anywhere else.

If the linker is giving you errors about missing util.c functions, you should add util to your module's .mk file, alongside your other module c files.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group