Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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

I'm puzzled because after a bit of Goggling, it has been confirmed that operator overloading ain't supported in standard C, but I read some people's comment mentioning LCC is ANSI-compliant.

So my real question is, is LCC really standard C or it's just like objective-c, a C variant with object-oriented features?

share|improve this question
    
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). –  Keith Thompson Oct 1 '12 at 8:56

5 Answers 5

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

share|improve this answer
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? –  caramel1995 Sep 4 '12 at 15:46
    
Since all valid C programs are valid Objective C programs, it could be considered an extension. –  Dirk Holsopple Sep 4 '12 at 15:52
    
So that's mean C++ is also a C variant since C code programs are valid C++ programs –  caramel1995 Sep 4 '12 at 15:55
8  
I think C++ and C standards conflict with each other now... –  speeder Sep 4 '12 at 16:03

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
    
Welcome. Thanks for posting your first answer on Stack Exchange Programmers. –  DeveloperDon Sep 30 '12 at 6:33

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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