(How to avoid) Compilation errors when using _start()

3 posts / 0 new
Last post
OldFart
OldFart's picture
Offline
Last seen: 4 months 2 weeks ago
Joined: 2010-11-30 14:09
(How to avoid) Compilation errors when using _start()

Hi,

The otherday I was simply compiling some stuff I had written many, many moons ago and came across a very strange compilation error.

Whilst compiling a program which is using '_start()' as its startingpoint in stead of the more common 'main()', I ran into a compilation error the meaning of which I felt hard to fathom as it was beyond all logic. Something about 'illegal type for _start()' and '_start() was defined here: .....'. I can't really reconstruct it as I've remedied the problem.

The problem only occured when including both 'dos/startup.h' and 'proto/utility.h>'.

This sequence would give offence to the compiler:

  1. #include <dos/startup.h>
  2. #include <proto/utility.h>

whereas this sequence would sooth the compiler:

  1. #include <proto/utility.h>
  2. #include <dos/startup.h>

The remedy I applied, albeit a crude one, was:

  1. #ifdef DOSLIB_STARTUP_H
  2. # error Include <proto/utility.h> BEFORE <dos/startup.h>!
  3. #endif

This nifty piece of preprocessor code went into 'proto/utility.h' right before:

  1. #ifndef UTILITY_UTILITY_H

Now the compilation halts issuing that error message. It is up to you to react according to it and from that moment onwards Bob's your uncle!

Thought I would let you know as it can become quite frustrating when one little piece of software compiles and the other doesn't and you are left clueless as to the why of it.

OldFart

cwenzel
cwenzel's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2021-01-12 07:05
Re: (How to avoid) Compilation errors when using _start()

This is completely unnecessary, you are missing an include file.
always include the proto/ headers for all libraries you are using FIRST.

The example code in include/dos/startup.h has everything you need.

OldFart
OldFart's picture
Offline
Last seen: 4 months 2 weeks ago
Joined: 2010-11-30 14:09
Re: (How to avoid) Compilation errors when using _start()

The example code in include/dos/startup.h has everything you need.

That was indeed the one that compiled properly and made me compare source code, the results of which led to my first posting.

The applied preprocessor error-line will now comfortably remind me of the proper sequence!

Thanks.

OldFart

Log in or register to post comments