How to compile an executable from more than one language source file?

Can you make an .exe from more than one language source file?

The reason I ask:

I want to make a project in C. But the GUI libraries that are compatible to C, such as the GTK+ project, I consider weak. And I am not keen on learning the WinApi either.

Is there any way for me to "pass on" all parameters calculated in the C executable to another language source file that *can* make better GUI's?
Yes, you can. But you'd have to be careful with making sure that the name mangling (if there is any) in the other languages you're using is "off" (not being used/expected), because C symbols are undecorated.

1
2
3
4
//C++ Example
extern "C" {
//All declarations here will have unmangled names.
}


Question, though. Is there any particular reason you have to mix C and some other language (as opposed to just completely using that other language)?

-Albatross
Last edited on
Albatross,

I am one of those people who will never jump ship when they dont understand the ship they are on.

In my quest to learn to programming, I decided to do C++ simply because it was the most talked about language and gave you the best of all worlds.

However when I started, too many concepts were so high level. Such as expecting me to use namespaces and classes when I could barely understand the essence of the language.

Thats when I decided, a year ago that I was to officially pursue C and understand the underlying low level ways of doing things.

I have not looked back ONCE. And the K&R textbook is simply GODLIKE. Its extremely difficult to disseminate and takes days on end to understand a page especially for a beginner like me.

Now having said all that, I have not yet mastered C. I am still on the K&R textbook and have not finished going through the whole of C.

The LAST thing I want to do, is drop the book or put C on hold and do something like Java or Python or whatever. I see these moves as half assed giving up on current languages. YES, I acknowledge that as a programmer you are expected to know more than one language but I will consider this once I finish C. By finish it I mean learn everything usefull about it: all sorts of linked list construction in C, all its libraries etc, etc...

I do have a feeling though that I might be using C for a very very long time. Im beginning to love it. Maybe im becoming just another Torvalds.

C has shit libraries for GUI. So I dont know how to "pass" its values onto another source to make the GUI for it...

EDIT: IN other words I want to keep using C while using the GUI power of other languages
Last edited on
Mixing languages is normally done at the binary level. You can call a dll/shared object written in C from a Java or Python application.

Albatross's name mangling comment applies in some cases. Old versions of VB could only call dlls which exposed __stdcall functions with no name mangling (I believe later versions of VB can use an alias to handle name mangling).

In others you've got to write the module in the correct way, for example: the Java Native Interface (JNI) requires a DLL to implement a set of functions for the Java VM to call.

Andy
Topic archived. No new replies allowed.