Author |
Message |
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: 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:
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:
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? |
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
Posted: 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.
Last edited by JoWie on Wed Jan 19, 2011 12:02 pm, edited 1 time in total |
|
Back to top |
|
|
Arnk Kilo Dylie Seasoned Helper
Age:36 Gender: Joined: Jul 14 2006 Posts: 108 Offline
|
Posted: 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. |
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: 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. |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: 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. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: 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? _________________ (Insert a bunch of dead links here) |
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: 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) |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: 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). |
|
Back to top |
|
|
Arnk Kilo Dylie Seasoned Helper
Age:36 Gender: Joined: Jul 14 2006 Posts: 108 Offline
|
Posted: 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. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: 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. |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: 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. |
|
Back to top |
|
|
|