delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/17/12:31:16

Message-ID: <D1FB30BBA491D1118E6D006097BCAE39280EF6@Probe-nt-2a.Probe.co.uk>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: Pascal units in c++
Date: Fri, 17 Apr 1998 17:28:25 +0100
MIME-Version: 1.0

Jasper van Woudenberg writes:
> ========== VESA.CPP ==========
> #ifndef _VESA_CPP_
> #define _VESA_CPP_
> 
> // function body's
> 
> #endif

There is no need for this in a C source file. The reason why these
defines are commonly placed around the contents of a header file, is
to prevent the file accidentally being included twice in a single
compile (eg. if a source included a particular header, but then also
included a different header which in turn includes the first header,
an error would occur if the contents of the first header were parsed
twice). C files must only ever be built once in any case, so this
cannot be a problem.

> I get an "undefined reference" in main() on the line which calls the
> function. 

You need to compile your module source (the .c file) into a .o file,
and then include this on the gcc command line when you build your
main program. For more information see the djgpp User's Guide
(http://www.delorie.com/djgpp/doc/ug/), or any decent C book: this
sort of basic language information is not really appropriate for
the djgpp newsgroup.

> BTW: how can i convert an object file to a library?

Use the ar program. See "info binutils ar".

	Shawn Hargreaves.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019