3

When I read about the LCC (Windows) compiler, I found out it has the implementation for operator overloading.

However, after a bit of Googling, I've confirmed that operator overloading isn't supported in standard C, although someone's comment mentioned LCC is ANSI-compliant.

Is LCC really standard C or is it just like objective-c, a C variant with object-oriented features?

1
  • I think you're using lcc-win, which is based on lcc but they're two different compilers. As I recall, it has an option to disable extensions and conform to the C standard (C99, I think). Oct 1, 2012 at 8:56

5 Answers 5

2

No, it's an extension. You're allowed to have extensions as long as they don't conflict with the standard.

5
  • 1
    Is objective-C an extension to original C?Is a language being considered as a new language(just like Objective-C) if it has added funationality(extension) to the language? Sep 4, 2012 at 15:46
  • Since all valid C programs are valid Objective C programs, it could be considered an extension. Sep 4, 2012 at 15:52
  • So that's mean C++ is also a C variant since C code programs are valid C++ programs Sep 4, 2012 at 15:55
  • 10
    I think C++ and C standards conflict with each other now...
    – speeder
    Sep 4, 2012 at 16:03
  • 2
    You're allowed to have extensions as long as they don't conflict with the standard -- True, but once you use the extensions, you're no longer C standard, unless the extensions are library-based (not compiler-based) and you can freely include the extension library in your own programs. Jan 31, 2015 at 19:34
0

Many compilers claim to be compliant to some standard or another, and then enable their own private extensions by default. As long as you disable enough extensions, you can typically get a compiler into a mode that's "compliant" to some standard.

The only C functionality that's remotely close to overloading is limited type-generic macros of <tgmath.h> in C99 and generic selection expressions in C11 as outlined on this site.

0

C11 does not support operator overloading. Compilers may implement their own vendor-specific functionalities but those are not part of the C standard and as such they aren't standard compliant.

0

It is common for compilers to support a superset of a standard and describe themselves as compliant.

As long as they handle code which conforms to the standard as the standard says they should then they are conforming. Many compilers have a command line flag which can be turned on to treat code more strictly, rejecting code which makes use of non-standard features. I'd imagine LCC will have such a flag.

2
  • Welcome. Thanks for posting your first answer on Stack Exchange Programmers. Sep 30, 2012 at 6:33
  • Actually, they must also issue a diagnostic on first use of any extension which breaks constraint making the program ill-formed. Feb 1, 2015 at 4:14
0

It looks to me like the LCC authors don't claim ANSI C compliance, but as you suggest in your question, have made their compiler support extensions to the C language.

"This document then, proposes the development of several enhancements to the language, mostly compatible with their C++ counterparts. The main aim is to make C programming easier, more secure and more flexible than it is now."

http://www.cs.virginia.edu/~lcc-win32/proposal.pdf

Operator overloading is definitely not part of ANSI C.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.