This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Extending C for Modules
- From: gnat-dev at buzco dot nyct dot net
- To: gcc at gcc dot gnu dot org
- Date: Wed, 5 Nov 2003 14:35:35 -0500
- Subject: Re: Extending C for Modules
- Organization: Buzco Systems International
- References: <20031105130912.B26536@datapex4.datapex.com>
- Reply-to: gnat-dev at buzco dot nyct dot net
On 03-11-05 13:09:12, Matt wrote:
| Are there any existing [GCC] C extensions for modules? If so, could someone
| post a link here?
| If not, I'd like to develop such an extension. Here's a summary of the
| features I want to implement:
| - Basic support for modules. (Physically, modules are just source files with
| associated object files.) Symbols are private by default (they must be
| explicitly made public), and don't automatically "carry" into including
| modules. (In this way modules work somewhat like namespaces.)
| - Automatic module init and cleanup. Modules can define two entry points (in
| addition to their other functions) for initialization and cleanup. The
| compiler would automatically determine module dependencies and call module
| init/cleanup functions in the appropriate places in user programs.
| - Automatic module linking. You shouldn't have to specify in two or more
| places what libraries or modules your program uses (usually an #include in
| source, and as a Makefile rule). The compiler will link your program against
| the modules you specify, via "import" or "uses" keywords in source.
| If anyone else has similar ideas/opinions, I'd like to hear about them.
=== End quoted text ===
Is there any reason you +must+ use (Ugh!) C ?
As I understand your requirements, they are all present already in
gcc-Ada.
In Ada: (s/unit/module/)
Every unit has its own public and private namespaces. The public
namespace may be imported into another unit or used explicitly
by prefixing the reference with the other unit name.
Every unit may have automatic initialization. Automatic finalization
is not quite as easy, but can be done.
Every Ada compiler must provide +some+ means to automatically link
to required units. (The keyword is "with".)
There are lots of other nifty features, starting with one thing that
C and all C-derived languages lack, READABILITY :).
In gcc-Ada, units required by the top (main program) unit are
recursively built (by gnatmake) as needed and automatically linked into
the resulting binary. Module dependencies are computed and
initialization done in proper order. You +may+ have to specify library
paths and names for the links, as well as extend the include path,
depending on how your source tree is set up.
Hope this helps,
== Buz :)
--
Buz Cory of BuzCo Systems -- New York NY USA http://BuzCo.nyct.net
<gnat-dev@BuzCo.nyct.net> (Buz as GNAT Programmer)
write to <helpdesk@BuzCo.nyct.net> for FREE help with:
Installing/Configuring Linux
Getting started with the Ada Programming Language.
Friends don't let friends do DOS; Linux to the rescue!
Ada 95 is here! Why use an archaic, bug-prone language?