This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Extending C for Modules


On Wed, Nov 05, 2003 at 01:09:12PM -0500, Matt wrote:
> Are there any existing [GCC] C extensions for modules? If so, could someone
> post a link here?

There's a rather popular C extension called C++.

> - 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.)

C++ has namespaces as well as classes.  However, even C has "static",
allowing a file to be treated as a module.

> - 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.

C++ has constructors and destructors, which can do what you want in this
area and more.

> - Automatic module linking. You shouldn't have to specify in two or more
>   places what libraries or modules your program uses (usually an #inclue 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.

C++ does not have this feature.  However, even in languages that have
features like this (scripting languages like Perl and Python), there is
information in two places: the import directives and the module search
path.  Or do what Java does, and force the file name to correspond to the
class being declared.

You'd need to have some convention as to where to find the module code.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]