[Bug 459] New: ORO_main should be optionally defined

For more infomation about this bug, visit
Summary: ORO_main should be optionally defined
Product: RTT
Version: rtt-trunk
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Operating System Abstraction - Portability
AssignedTo: orocos-dev [..] ...
ReportedBy: peter [dot] soetens [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

A potential disadvantage of using Orocos::RTT as a library is that it requires
an application to implement the ORO_main function. This should be optional
such that a user can choose to use main() and, if necessary (for LXRT for
example), call the OS setup functions manually.

The current implementation has also the disadvantage that the liborocos-rtt.so
has an undefined symbol (ORO_main) at link time, which may result in link
errors on some operating systems.

This can be easily fixed by defining ORO_main as a C macro in rtt/os/main.h
which wraps around main() and drop main() from rtt/os/main.cpp

Using ORO_main _has_ advantages (catching C++ exceptions, setting an 'alive'
signal on the thread scope) and will be recommended, but if you're fine without
that, you should have the option.

[Bug 459] ORO_main should be optionally defined

For more infomation about this bug, visit

Peter Soetens
<peter [dot] soetens [..] ...> changed:

What |Removed |Added
--------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |1.4.0

--- Comment #2 from Peter Soetens
<peter [dot] soetens [..] ...> 2007-10-29 12:51:01 ---
$ svn ci -m"Fix bug #459: ORO_main should be optionally defined
> This solves link issues on Mac OS X as well.
> "
Deleting os/main.cpp
Sending os/main.h
Sending os/startstop.cpp
Sending os/startstop.h
Transmitting file data ...
Committed revision 28673.

[Bug 459] ORO_main should be optionally defined

For more infomation about this bug, visit

Peter Soetens
<peter [dot] soetens [..] ...> changed:

What |Removed |Added
--------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|orocos- |peter [dot] soetens [..] ...
|dev [..] ... |

--- Comment #1 from Peter Soetens
<peter [dot] soetens [..] ...> 2007-10-26 15:28:18 ---
Created an attachment (id=158)
--> (https://svn.fmtc.be/bugzilla/orocos/attachment.cgi?id=158)
No longer require ORO_main and define it as a macro

This patch removes the file main.cpp and puts the majority of the code in
startstop.cpp. main.h is extended with a tiny wrapper macro which expands if
the user uses ORO_main.

If the user does not use ORO_main but still wants to initialize the RTOS, he
needs to include and then call __os_init(argc,argv); at
the beginning of main() and call __os_exit() at the end of main(). These
functions setup the RTT/RTOS runtime.