News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Why do I need a inc file

Started by Gadersd, August 05, 2013, 02:06:26 PM

Previous topic - Next topic

Gadersd

Hi, I just started MASM and I need some help. I just created a SDL lib file and whenever I try to use SDL functions using call, MASM tells me that the SDL functions are undefined symbols. I read somewhere that I don't need a inc file unless I use invoke. What am I doing wrong?

TouEnMasm


ALL used functions must have a declaration prototype.
The prototype can be C , BASIC, FORTRAN, PASCAL, SYSCALL, STDCALL.
and so on with number and type of arguments.

Before the call , masm must know all this details to write it.

Fa is a musical note to play with CL

hutch--

Hi Gadersd,

Welcome on board. You can write code the way you suggest but you are doing it the hard way and with a highly reduced chance of success if you try and avoid prototypes. In MASM code you can have local procedures, library procedures or import libraries and they generally use an identical type of prototype for all of them.

A prototype does something very basic in MASM, it tells the assembler BEFOREHAND what the argument count and sizes are and this allows MASM to use the INVOKE notation with some limited but useful checking so that you don't make a mess of a procedure call. Windows has something like 12000 API functions, most of which are prototyped for you in the include files where if you try and do it the hard way you have to manually call each procedure or API.

Gadersd

Do you know of a program that can convert SDL.def to SDL.inc so that I don't have to do it manually.

qWord

You can use Japheth's h2incX for conversion of the headers (sometimes it is required to correct the translation at some points, which is maybe hard for people who are new to MASM).
For SDL 1.2, there is already a translation: see the WinInc site.
MREAL macros - when you need floating point arithmetic while assembling!

Gadersd

What do the langtypes mean in masm? How do I choose which one to use in proto?

dedndave

#6
for most stuff we do in here, we use StdCall, which is the default

MyFunc PROTO :HWND,:LPSTR,:DWORD

Vortex

Quote from: Gadersd on August 06, 2013, 12:03:57 AM
Do you know of a program that can convert SDL.def to SDL.inc so that I don't have to do it manually.

def2inc can convert module definition files to include files.