Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How to prototype.h files? based on assembler programs

Posted on 2005-04-10
Medium Priority
Last Modified: 2010-04-01
This is my float.h

#ifndef _FLOTANTE_H
#define _FLOTANTE_H

#define MyProc __MyProc
extern "C" __stdcall __MyProc(float,float);

float MyProc(float var1, float var2);

This is my Assembly code


.model flat, stdcall

option casemap:none

;include \masm32\include\windows.inc
;include \masm32\include\kernel32.inc



Myproc proc var1:REAL4, var2:REAL4
    LOCAL retval:REAL4
    fld var1
    fld var2
    fstp retval
    fwait                ;<- is this really needed?
    mov eax, retval
Myproc endp


And this is my C code.

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
#include "H:\Practica Arquitectura del Computador\include\flotantes.h"

float MyProc(float, float);

void sum(void)
     float total2;
     total2 = MyProc(3.2, 4.2);
     printf("Total is: %d", total2);

But I have this error

Compilador: Default compiler
Building Makefile: "H:\Practica Arquitectura del Computador\Makefile.win"
Ejecutando  make...
make.exe -f "H:\Practica Arquitectura del Computador\Makefile.win" all
gcc.exe -c test/pentium/main.c -o test/pentium/main.o -I"C:/Dev-Cpp/include"  -I"H:/Practica Arquitectura del Computador/include"  

gcc.exe test/pentium/main.o  -o "test\pentium\Practica.exe" -L"C:/Dev-Cpp/lib" src/pentium/pentium.obj  

test/pentium/main.o(.text+0xdc):main.c: undefined reference to `MyProc'
collect2: ld returned 1 exit status

make.exe: *** [test/pentium/Practica.exe] Error 1

Ejecución Terminada
Question by:djhex
1 Comment
LVL 22

Accepted Solution

grg99 earned 2000 total points
ID: 13751868
Could be one of three things:

(1)  You didnt include the assembly source file in the list of files to compile and assemble.

(2)  The name of the assembly .o file didnt get passed to the linker

(3)  The function names are not exactly matched up.

You'll have to look at the gcc conventions for external names.  

This varies from compiler to compiler.  Some Prepend an underline.  Some postpend an underline, or two.

Some assemblers uppercase all external names, some dont.

You could run a "strings" or "dumpobj" over the .o files and see if "MyProc" shows up in the .o files with the exact same capitalization and underline decorations.


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question