unresolved external thats not external???

Programming, for all ages and all languages.
Post Reply
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

unresolved external thats not external???

Post by LordMage »

I am trying to implement a memset function in my OS but when I compile I get

Code: Select all


error LNK2019: unresolved external symbol _memset referenced in function "void _stdcall memset(unsigned char *,unsigned char,int)"(?memset@@YGXPAEEH@Z)

what I don't understand is that memset is not an external function and it certainly doesn't call itself from inside the function. any ideas?
Getting back in the game.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

You are compiling C++ correct? The name mangling seems to suggest that. Try putting extern "C" before the definition and the prototype of memset. Also make sure that your not including any system libraries.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

it means that memset has a reference to _memset somewhere which is not implemented.

btw, is this Visual C ?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

Post by LordMage »

Okay, first I have not included a memset anywhere except the prototype and the actual function declaration.

second yes this is Visual C++ and I am not using any system libraries, the only code in my project is code I have written. everything works just fine except memset thinks it should have an external definition.

in my string.cpp I have this line

Code: Select all


#include <system.h>

in my system.h I have this line

Code: Select all


#include <string.h>

in my string.h I have the prototype of memset and I think I just figured out the problem. I'll bet that if I put #include <string.h> in string.cpp and put extern memset in system.h then everything will work just fine. I will test later today, thanks for the push
Getting back in the game.
Post Reply