We help IT Professionals succeed at work.

Using Visual Studio 6 writing a C program and getting errors

--------------------Configuration: StockCharter - Win32 Release--------------------
Compiling...
StdAfx.cpp
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\objbase.h(435) : error C2664: 'memcmp' : cannot convert parameter 1 from 'const struct _GUID *' to 'void *'
        Conversion loses qualifiers
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\objbase.h(459) : error C2664: 'memcmp' : cannot convert parameter 1 from 'const struct _GUID *' to 'void *'
        Conversion loses qualifiers
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(68) : error C2733: second C linkage of overloaded function '_memccpy' not allowed
        C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(68) : see declaration of '_memccpy'
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(69) : error C2733: second C linkage of overloaded function 'memchr' not allowed
        C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(69) : see declaration of 'memchr'
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(70) : error C2733: second C linkage of overloaded function '_memicmp' not allowed
        C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(70) : see declaration of '_memicmp'
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(76) : error C2733: second C linkage of overloaded function 'memcmp' not allowed
        C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(76) : see declaration of 'memcmp'
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(77) : error C2733: second C linkage of overloaded function 'memcpy' not allowed
        C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(77) : see declaration of 'memcpy'
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(85) : error C2733: second C linkage of overloaded function 'memccpy' not allowed
        C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(85) : see declaration of 'memccpy'
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(86) : error C2733: second C linkage of overloaded function 'memicmp' not allowed
        C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\memory.h(86) : see declaration of 'memicmp'
Error executing cl.exe.
Creating browse info file...

StockCharter.exe - 9 error(s), 0 warning(s)
Comment
Watch Question

evilrixSenior Software Engineer (Avast)

Commented:
Let's start with the obvious errors and see where we go from there.

C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\objbase.h(435) : error C2664: 'memcmp' : cannot convert parameter 1 from 'const struct _GUID *' to 'void *'
        Conversion loses qualifiers
C:\Program Files (x86)\Microsoft Visual Studio\VC98\INCLUDE\objbase.h(459) : error C2664: 'memcmp' : cannot convert parameter 1 from 'const struct _GUID *' to 'void *

This error suggests you have a mismatched with constness. Have you looked at this to see why?

Also, seeing the code would help.
Software AssembliesSoftwareAssemblies.com

Author

Commented:
how would I solve this issue?
Software AssembliesSoftwareAssemblies.com

Author

Commented:
if this is C program why is it picking up C++ errors?
Top Expert 2016
Commented:
you should remove stdafx.cpp from your project. this source most probably would compile as a c++ source (by default because of .cpp extension) but if you have chosen ansi-c as the compiler you might get some very strange errors like the ones you posted. stdafx.cpp is the source that should provide the so-called precompiled header (pch) which would make faster builds for all source files which included stdafx.h as first header file. stdafx.h mostly includes a lot of c++ headers and with the pch feature those classes and their inline functions are compiled only once.

in your project the precompiled headers seem to be a wrong decision when you created the project. especially when you intend to build with the c compiler. you should go to the c/c++ project settings and choose the precompiled header tab. there you can specify that the precomiled headers are not be used for your project. you have to do this for both debug and release configuration.  if you have a c project you additionally should remove all #include "stdafx.h" from your sources (in case of c++ you may use those include statements regardless if pch is switched on or off).

Sara
Top Expert 2016

Commented:
by the way vs 6 is from 1998 and was released before first c++ standard (c++98). if you want to have a c program, you much better would use visual studio 2017 community which is 19 years younger and for free. it still has an excellent ansi-c compiler.

Sara
evilrixSenior Software Engineer (Avast)

Commented:
>> if this is C program why is it picking up C++ errors?
Why do you think they are C++ errors?

>> how would I solve this issue?
Well, you have a const/non-const mismatch and so you'll either have to make one argument const or the other non-const. Without being able to see the code (as I've asked you to provide), we can't really say much more without resorting to telepathy or asking our spirit guides. :)
Top Expert 2016

Commented:
Why do you think they are C++ errors?

stdafx.cpp is a wizard-generated c++ source which has only one (include) statement: #include "stdafx.h"

the extension .cpp is a reasonable indication that stdafx.cpp is compiled by using the c++ compiler. nevertheless vs studio settings would allow to compile even a source named stdafx.cpp with ansi-c compiler if all headers included by stdafx.h can be included as c headers as well. however, this can't work if the generated stdafx.h source included headers with some inline functions which are not compliant with strict ansi c syntax.

Sara