News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

PUBLIC, EXTRN ?

Started by xandaz, December 18, 2010, 01:28:40 AM

Previous topic - Next topic

xandaz

    I've been having some trouble understanding how to manage data structures and arrays of some kind that are common to different source files. I mean fa.: i want to write a an app of any kind and want to use a main source file with the program's essencials and several other source files dedicated by subject. If some data that is declared on the main source file is used by a function on another source file that is mentioned as an inclusion on the main file i get the undefined symbol error. Should i use the public and extrn directives or this is history? There are simpler ways to do this, right? Thanks and bye

GregL

xandaz,

You could use PUBLIC and EXTERN, but EXTERNDEF makes things easier.  Attached is an example of using EXTERNDEF.


When trying to upload the 4 KB file I got the following message:

Quote from: The MASM ForumAn Error Has Occurred!
The upload folder is full. Please try a smaller file and/or contact an administrator.

I'll upload the example when I can.  Look up EXTERNDEF in the MASM Programmer's Guide.


GregL

Still can't upload the file.

Dave,

This example takes it a step further.


It boils down to this:  You can put the EXTERNDEF statements in an include file and just include that file in each module that either defines or references the data.  It will act as either PUBLIC, EXTERN or will be ignored as required.

EXTERNDEF

hutch--

Sorry about that, it was a server setting. Added an extra 250 meg so it will be a while before it happens again.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

GregL

Thanks Hutch. :bg

I'll attach the example file here.

dedndave


GregL

Dave,

You bet.  :bg

Sorry about the paths in make.cmd, I fixed them up and uploaded again.

xandaz