Hello,
I'm using visual studio 6.0 sp 5 with the processor pack.
I would like use a C variable with my C program but visual c giving me
and unreconized symbol, and i don't know why :/
test.obj : error LNK2001: unresolved external symbol _toto
Debug/uuu.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
uuu.exe - 2 error(s), 0 warning(s)
I'm pasting my example :
1. I'm creating a visual studio Console project and i'm writting the
folliwing code :
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
extern "C" void compute();
char *toto;
void main(void)
{
int i;
toto = ( char *) calloc (11, sizeof( char));
compute();
/*for (i = 0 ; i < 10 ; i++)
{
toto[i] = 'A'+i;
}*/
printf("%s",toto);
//getch();
free(toto);
}
2. The Asm program :
..586
..model flat,C
public compute
extrn toto:dword ; i tried to put extrn _toto:dword , extrn _toto :
byte, extrn toto : byte, and i don't works :/
..data
zeroo dd 0
..code
compute proc
mov esi, toto ; idem for extrn , i tried _toto too
mov eax,'A'
xor ecx,ecx
_loop:
mov byte ptr [esi],al
inc ecx
inc esi
inc eax
cmp ecx,10
jne _loop
ret
compute endp
end
3. I'm setting up the asm file compilation directive : Custom build :
ml.exe -c -coff -Cx -Fo$(IntDir)\$(InputName).obj $(InputName).asm
and outputs : $(IntDir)\$(InputName).obj
Thanks you for your help, and please accept my apologize for my bad
english :/ Have a nice day ;o)
Sincerly,
skweek
|
|
0
|
|
|
|
Reply
|
skweek
|
2/24/2005 6:31:28 PM |
|
Apart from its probably better to use EXTERNDEF with ML 6.15, I think
your problem is you are not making the C variable "todo" visible to the
asm procedure. My C is too rusty but you need something like PUBLIC for
the address of the todo string buffer as you must remember that the
MASM code is in a seperate module and has no way of accessing the
string address.
Looking at your code, I don't see why you don't just pass it as a
parameter to the module in assembler. It would solve these basic scope
issues.
Regards,
hutch at movsd dot com
|
|
0
|
|
|
|
Reply
|
hutch
|
2/24/2005 7:48:24 PM
|
|
"skweek" <spamtrap@crayne.org> wrote in message
news:cvkf5k$s08$1@biggoron.nerim.net...
> Hello,
>
> I'm using visual studio 6.0 sp 5 with the processor pack.
> I would like use a C variable with my C program but visual c giving me and
> unreconized symbol, and i don't know why :/
>
> test.obj : error LNK2001: unresolved external symbol _toto
> Debug/uuu.exe : fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
>
> uuu.exe - 2 error(s), 0 warning(s)
>
> I'm pasting my example :
>
> 1. I'm creating a visual studio Console project and i'm writting the
> folliwing code :
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <conio.h>
>
> extern "C" void compute();
> char *toto;
[...]
You are using the C++ language, not C, and there is a big difference when it
comes to naming. C++ name mangling means that toto will not be emitted as
_toto. I don't know the syntax rules on extern, but this seems to work for
me:
extern "C"
{
char *toto;
};
That should cause toto to have the name _toto instead of
_toto?@somereally@l??ongstr?ingthate?ncodes##typeinf@ormation.
-Matt
|
|
0
|
|
|
|
Reply
|
Matt
|
2/24/2005 11:21:07 PM
|
|
> > extern "C" void compute();
> > char *toto;
> [...]
>
> You are using the C++ language, not C, and there is a big difference when it
> comes to naming. C++ name mangling means that toto will not be emitted as
> _toto. I don't know the syntax rules on extern, but this seems to work for
> me:
>
> extern "C"
> {
> char *toto;
> };
That's okay, and there are another syntax to write:
Solution 1:
extern "C" char *toto;
Solution 2:
extern "C"
{
void compute();
char *toto;
}
If you use 'extern "C"' so often, these macros will help:
#ifdef __cplusplus
#define BEGIN_EXTERN_C extern "C" {
#define END_EXTERN_C }
#else
#define BEGIN_EXTERN_C
#define END_EXTERN_C
#endif
This is the way that compilers' header files do.
========================================================================
(Mr.) IIJIMA Hiromitsu, mailto:delmonta@ht.sakura.ne.jp
aka Delmonta http://www.ht.sakura.ne.jp/~delmonta/
There are more than one ways for doing the same thing. --- Larry Wall
|
|
0
|
|
|
|
Reply
|
IIJIMA
|
2/25/2005 1:59:07 AM
|
|
IIJIMA Hiromitsu a écrit :
>>>extern "C" void compute();
>>>char *toto;
>>
>>[...]
>>
>>You are using the C++ language, not C, and there is a big difference when it
>>comes to naming. C++ name mangling means that toto will not be emitted as
>>_toto. I don't know the syntax rules on extern, but this seems to work for
>>me:
>>
>>extern "C"
>>{
>> char *toto;
>>};
>
>
> That's okay, and there are another syntax to write:
>
> Solution 1:
> extern "C" char *toto;
>
> Solution 2:
> extern "C"
> {
> void compute();
> char *toto;
> }
>
>
> If you use 'extern "C"' so often, these macros will help:
>
> #ifdef __cplusplus
> #define BEGIN_EXTERN_C extern "C" {
> #define END_EXTERN_C }
> #else
> #define BEGIN_EXTERN_C
> #define END_EXTERN_C
> #endif
>
> This is the way that compilers' header files do.
>
> ========================================================================
> (Mr.) IIJIMA Hiromitsu, mailto:delmonta@ht.sakura.ne.jp
> aka Delmonta http://www.ht.sakura.ne.jp/~delmonta/
>
>
> There are more than one ways for doing the same thing. --- Larry Wall
>
Thanks you very much for your help :)
Sincerly
Skweek
|
|
0
|
|
|
|
Reply
|
skweek
|
2/25/2005 7:15:45 PM
|
|
Matt a �crit :
> "skweek" <spamtrap@crayne.org> wrote in message
> news:cvkf5k$s08$1@biggoron.nerim.net...
>
>>Hello,
>>
>>I'm using visual studio 6.0 sp 5 with the processor pack.
>>I would like use a C variable with my C program but visual c giving me and
>>unreconized symbol, and i don't know why :/
>>
>>test.obj : error LNK2001: unresolved external symbol _toto
>>Debug/uuu.exe : fatal error LNK1120: 1 unresolved externals
>>Error executing link.exe.
>>
>>uuu.exe - 2 error(s), 0 warning(s)
>>
>>I'm pasting my example :
>>
>>1. I'm creating a visual studio Console project and i'm writting the
>>folliwing code :
>>
>>#include <stdio.h>
>>#include <stdlib.h>
>>#include <conio.h>
>>
>>extern "C" void compute();
>>char *toto;
>
> [...]
>
> You are using the C++ language, not C, and there is a big difference when it
> comes to naming. C++ name mangling means that toto will not be emitted as
> _toto. I don't know the syntax rules on extern, but this seems to work for
> me:
>
> extern "C"
> {
> char *toto;
> };
>
> That should cause toto to have the name _toto instead of
> _toto?@somereally@l??ongstr?ingthate?ncodes##typeinf@ormation.
>
Thanks you very much :))
I doesn't know this concept of name mangling :/ Are you more information
which can giving more information name notation :
_toto?@somereally@l??ongstr?ingthate?ncodes##typeinf@ormation. ?
I'm solving my problems thanks to you. :)))
Sincerly
Skweek
|
|
0
|
|
|
|
Reply
|
skweek
|
2/25/2005 7:15:52 PM
|
|
hutch-- a �crit :
> Apart from its probably better to use EXTERNDEF with ML 6.15, I think
> your problem is you are not making the C variable "todo" visible to the
> asm procedure. My C is too rusty but you need something like PUBLIC for
> the address of the todo string buffer as you must remember that the
> MASM code is in a seperate module and has no way of accessing the
> string address.
>
> Looking at your code, I don't see why you don't just pass it as a
> parameter to the module in assembler. It would solve these basic scope
> issues.
I'm trying to rewrite an old program of my firm. I looking for the best
compromise in my situation to have a good code the most portable. And my
choice is to call a pointer which will be allocated by a
(malloc/calloc), and this pointer will be modified for critical
procedure via a assembly code.
I have solving my problem via extern "C" type *myvar; and on asm file :
..model flat,c
..586
..data
extrn myvar:dword
..code
;the program
end
Thanks for all :))
Sincerly
skweek
|
|
0
|
|
|
|
Reply
|
skweek
|
2/25/2005 7:15:56 PM
|
|
|
6 Replies
116 Views
(page loaded in 0.153 seconds)
Similiar Articles: ASM to C - comp.lang.asm.x86The solution was a simple asm to c translator, that had ... See Morgan book for detailed flow graph compilation ... Phone: (612) 371-2023 Pragmatic C Software Corp ... assembly for boot sectors - comp.lang.asm.x86... to how good you are on programming asm while in C ... missing" I have most likely made a mistake. My boot sector program is ... But... if you compile a C program... could you ... External variables - comp.lang.asm.x86... of seeing how the pieces come together and what a C program ... pointers (yes I know that), and I could never did that mistake in straight C, I never used them in asm ... Calling MATLAB from Visual Studio in a C program - comp.soft-sys ...I think you would probably have to do the compilation using VS (so you need ... From NASM to Visusal Studio source debugging - comp.lang.asm.x86 ... debugging c program - comp ... NASM on WINXP x64 creating EXE - comp.lang.asm.x86I'm using NASM 2.07 on winxp x64 trying to create a 64 bit ASM exe and ... nasm -f win64 -o tiny.exe tiny.asm Please tell me what simple mistake I'm making as the program ... See Source code of *.dll file - comp.fontsI'm working with a software camera, and I need to change ... Compilation is a one-way process, once its omplete there is ... How to get a .lib from .dll - comp.lang.asm.x86 See ... Making programs more Vista/7 compatible - comp.os.ms-windows ...I maintain a couple well-behaved Windows 32 bit program that need ... NASM on WINXP x64 creating EXE - comp.lang.asm.x86 Please tell me what simple mistake I'm making as the ... input & output in assembly - comp.lang.asm.x86Of course, now that you've downloaded the handy "HelpPC" program, which neatly divides up lots of ASM ... bus), and in order to access more memory than Very common mistake ... Cross-Compile for ARM - NTP 4.1.1 OK, NTP 4.2.0a Errors - comp ...... error: unknown register name st(1) in 'asm ... ThunderBolt, so we can use Linux/ACE timers for software ... The compilation itself goes ok ... and ARM - comp.arch Cross ... Windows API programming with gfortran or g95 - comp.lang.fortran ...Aahhh yes---Directive-Enhanced Compilation. I'm sure ... WinMain = 0 > end function WinMain > !end program WinMain > > C ... device driver for win32 - comp.lang.asm.x86 ... unable to resolve compilation error;./List.c:5: error: expected ...unable to resolve compilation error;./List.c:5: error: expected ... keys to understand the philosophy of free software ... sorry i had made a mistake in copying the code i ... Compiler - Wikipedia, the free encyclopediaA compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer ... 7/22/2012 9:18:05 AM
|