Compatibility with C

Forum for talking about anything else Ecere/eC related.
Post Reply
jonaspm
Posts: 49
Joined: Thu Apr 11, 2013 11:04 pm
Location: Mexico
Contact:

Compatibility with C

Post by jonaspm »

I got a question:
Is Ecere 100% compatible with C?

thanks in advance
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Compatibility with C

Post by jerome »

Hi Jonas,

eC aims to be a superset of C, being as compatible with C as possible while keeping a neat syntax.
I'd say it's 99% C compatible.
Examples of things that are not fully C compatible:

- C code that would use reserved eC keywords, e.g. 'property', 'class'
(A work around to include C headers that use this is to #define, #include, and #undef)
- C style structs and typedefs -- eC tries to handle both eC style structs that define a type without using a typedef, and C style structs. There maybe some border-line cases however where there is ambiguity and eC's understanding will prevail.
- There may still be some bugs and limitations in the compiler where compatibility would in effect be broken.

In an eC project, you can mix and match eC, C and C++ files.

eC will export symbols just like C would (unmangled), unless you are using the eC namespaces (the namespace will mangle the symbols).

Please let me know if you have more specific questions regarding this!

Regards,

Jerome
jonaspm
Posts: 49
Joined: Thu Apr 11, 2013 11:04 pm
Location: Mexico
Contact:

Re: Compatibility with C

Post by jonaspm »

thank you so much for the quick and complete answer Jerome :D
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Compatibility with C

Post by jerome »

I forgot to mention, eC has 4 declaration modes:

private: Things are visible inside the library/exe only.
public: Things are visible to libraries and executables importing this library.
static: Things are visible only inside this source file.
default: C compatibility mode

By default eC is in private mode.
But anything included from a .h header is automatically in default (C compatibility mode).

In this mode there is no ambiguity with the C style structs, they will always be understood as C structs. To write a header that defaults to eC style private mode, use the .eh extension instead. But there is rarely a need for writing headers in eC, as the import mechanism works very well.

Basically there should not be any issue including headers for and linking with a C library, or in fact any library that exposes C bindings. If you come across a library that you're having trouble with, I will be happy to help you resolve it. But then the Ecere library comes loaded with functionality, so a lot is already covered!

Regards,

Jerome
jonaspm
Posts: 49
Joined: Thu Apr 11, 2013 11:04 pm
Location: Mexico
Contact:

Re: Compatibility with C

Post by jonaspm »

Thank You!!!
Post Reply