Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > GCC is re-implementing in C++ and C discarded

Reply
Thread Tools

GCC is re-implementing in C++ and C discarded

 
 
Andrew Smallshaw
Guest
Posts: n/a
 
      08-27-2012
On 2012-08-24, Kenneth Brody <(E-Mail Removed)> wrote:
> On 8/23/2012 1:43 PM, Kenny McCormack wrote:
>>
>> I suggest that the most common interpretation of this question is:
>>
>> Q: What language should I study in school to maximize my chances of getting
>> a job?

>
> Q: If it's more likely that I can get a job with language X, but getting a
> job with language Y pays more, which language should I study?


Good point. Another would be the longevity of the language. Five
or ten years ago there were any number of VB programming jobs out
there typically offering salaries not much more than what an average
network technician can command. I've no concrete evidence to back
this up but my impression is that the number of adverts has dropped
at least an order of magnitude from its peak. PHP seems to be the
current flavour of the month.

--
Andrew Smallshaw
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
lovecreatesbeauty
Guest
Posts: n/a
 
      08-27-2012
On Monday, August 27, 2012 4:04:57 AM UTC, Keith Thompson wrote:
> lovecreatesbeauty <(E-Mail Removed)> writes:
>
> > On Saturday, August 25, 2012 7:18:22 PM UTC, Keith Thompson wrote:

>
> [...]
>
> >> Even so, the existence of a C++ implementation that generates C code
> >> doesn't imply anything about upwards compatibility. A C program
> >> that uses `new` as an identifier is still an invalid C++ program.

>
> > Even their main function aren't compatible, how could they be
> > compatible then?

>
> int main(void) { }
>
> is perfectly valid in both C and C++, as is
>
> int main(int argc, char *argv[]) { }
>
> C++ adopted the "(void)" syntax specifically to maintain compatibility
> with C.
>
> Even the preferred C++ form:
>
> int main() { }
>
> , though there's some question about whether it's completely valid in C,
> is accepted without complaint by most or all C compilers.
>


I saw some C++ code like

void main()
{
/*...*/
}
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      08-27-2012
lovecreatesbeauty <(E-Mail Removed)> writes:
[...]
> I saw some C++ code like
>
> void main()
> {
> /*...*/
> }


How is that relevant?

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      08-27-2012
On 08/27/2012 03:19 AM, lovecreatesbeauty wrote:
> On Monday, August 27, 2012 4:04:57 AM UTC, Keith Thompson wrote:
>> lovecreatesbeauty <(E-Mail Removed)> writes:

....
>>> Even their main function aren't compatible, how could they be
>>> compatible then?

....
> I saw some C++ code like
>
> void main()
> {
> /*...*/
> }


Well, I saw some C code like that too. Both languages define two
specific ways of defining main() that are guaranteed supported by every
hosted conforming implementation, this isn't one of them (C:5.1.2.2.1p1,
C++:3.6.1p2). Both languages explicitly allow an implementation to
accept additional forms, and many popular compilers for each language
will accept this form. Both standards fail to describe what happens if
you try to use a form not supported by your implementation, so the
behavior when you do so is undefined by reason of the absence of a
definition. (C:4p6, C++:1.3.13p3).

I don't see any relevant differences between the two languages in this
regard. Could you explain more fully how this constitutes an example of
incompatibility between C and C++?
--
James Kuyper
 
Reply With Quote
 
lovecreatesbeauty
Guest
Posts: n/a
 
      08-27-2012
On Monday, August 27, 2012 12:26:11 PM UTC, James Kuyper wrote:
> On 08/27/2012 03:19 AM, lovecreatesbeauty wrote:
>
> > On Monday, August 27, 2012 4:04:57 AM UTC, Keith Thompson wrote:

>
> >> lovecreatesbeauty <(E-Mail Removed)> writes:

>
> ...
>
> >>> Even their main function aren't compatible, how could they be

>
> >>> compatible then?

>
> ...
>
> > I saw some C++ code like

>
> >

>
> > void main()

>
> > {

>
> > /*...*/

>
> > }

>
>
>
> Well, I saw some C code like that too. Both languages define two
>
> specific ways of defining main() that are guaranteed supported by every
>
> hosted conforming implementation, this isn't one of them (C:5.1.2.2.1p1,
>
> C++:3.6.1p2). Both languages explicitly allow an implementation to
>
> accept additional forms, and many popular compilers for each language
>
> will accept this form. Both standards fail to describe what happens if
>
> you try to use a form not supported by your implementation, so the
>
> behavior when you do so is undefined by reason of the absence of a
>
> definition. (C:4p6, C++:1.3.13p3).
>


Hi James,

Thanks for reading.

I'm dumb. I meant in my previous message the following is valid C++ but illegal C.

int main() { /* ... */ }

What I hate about C++ is that it changes the C then adds extra features.

Objective-C just adds some other messaging features on C, and it leaves C unchanged. Its messaging parts are ugly though.

If the latest C11 paperwork had enriched the C library with more general data structures like list, queue, stack and common and algorithms on them like sort, search, that would be enough.
 
Reply With Quote
 
Vincenzo Mercuri
Guest
Posts: n/a
 
      08-27-2012
On 27/08/2012 16:36, lovecreatesbeauty wrote:
[..]
> If the latest C11 paperwork had enriched the C library with more general data structures like list, queue, stack and common and algorithms on them like sort, search, that would be enough.


Then you should program in C++. If you need those extra features in the
C language you need C++. Demanding the Standard to make such a huge
change to the language is just nonsensical (to me).

--
Vincenzo Mercuri
 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      08-27-2012
On 08/27/2012 10:36 AM, lovecreatesbeauty wrote:
....
> ... I meant in my previous message the following is valid C++ but illegal C.
>
> int main() { /* ... */ }


What gives you that impression? What rule do you think it breaks?
 
Reply With Quote
 
Jens Gustedt
Guest
Posts: n/a
 
      08-27-2012
Am 27.08.2012 16:36, schrieb lovecreatesbeauty:
> I'm dumb. I meant in my previous message the following is valid C++ but illegal C.
>
> int main() { /* ... */ }


That is not so clear that it is illegal in C. The rules for
definitions of functions are more relaxed than those for pure
declarations. An empty list in a definition means that the function
doesn't receive any arguments, which is in accordance with one of the
two prototypes that are foreseen for main.

int foo(void);

and

int foo() { /* ... */ }

are compatible, I think.

So there is not really a problem here.

Jens
 
Reply With Quote
 
Vincenzo Mercuri
Guest
Posts: n/a
 
      08-27-2012
On 27/08/2012 18:27, James Kuyper wrote:
> On 08/27/2012 10:36 AM, lovecreatesbeauty wrote:
> ...
>> ... I meant in my previous message the following is valid C++ but illegal C.
>>
>> int main() { /* ... */ }

>
> What gives you that impression? What rule do you think it breaks?
>


I think it is implementation-defined whether it is supported or not,
even though almost all the implementations do support it. But I'd say
that it is not the "most portable" way to define main.

--
Vincenzo Mercuri
 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      08-27-2012
On 08/27/2012 01:11 PM, Vincenzo Mercuri wrote:
> On 27/08/2012 18:27, James Kuyper wrote:
>> On 08/27/2012 10:36 AM, lovecreatesbeauty wrote:
>> ...
>>> ... I meant in my previous message the following is valid C++ but illegal C.
>>>
>>> int main() { /* ... */ }

>>
>> What gives you that impression? What rule do you think it breaks?
>>

>
> I think it is implementation-defined whether it is supported or not,


Citation, please?

> even though almost all the implementations do support it. But I'd say
> that it is not the "most portable" way to define main.


The standard describes two ways of defining main(), and requires every
conforming implementation of C to support any definition of main
equivalent to one of those two ways. This form is not the same as either
one of those, but it is equivalent to the first of those two ways. The
same is true of the C++ standard. Therefore, I'd expect it to be
extremely portable. What gives you doubts on the matter?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: GCC is re-implementing in C++ and C discarded Nomen Nescio C Programming 0 08-26-2012 10:34 AM
Re: GCC is re-implementing in C++ and C discarded Anonymous C Programming 10 08-26-2012 08:04 AM
Cisco VPN client, packets beeing discarded and bypassed seansan Cisco 3 09-24-2006 10:50 AM
discarded iterator.next() at interactive global scope doesn't bump interator?? Bengt Richter Python 2 09-04-2005 12:17 PM
Linker Message: "discarded section" Hartmut Sbosny C++ 2 05-29-2005 12:20 AM



Advertisments