Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > some well known stupidness in c99

Reply
Thread Tools

some well known stupidness in c99

 
 
fir
Guest
Posts: n/a
 
      11-18-2012
It is sad to say so but there is some real
and terrible stupidnes in c99. When i wrote
programs in c (and I am involved c user) I
just use const int for array boundaries but
in c99 (and some previous too, terribly) it
will not compile (see for example
http://stackoverflow.com/questions/1...-at-file-scope ) It is terribly wrong
thing for ppl who just wants to use const int to this
purposes and not to use preprocesor - as I do.
It is terribly stupidness in my opinion, it have to
be changed.

 
Reply With Quote
 
 
 
 
Thomas Richter
Guest
Posts: n/a
 
      11-18-2012
Am 18.11.2012 10:21, schrieb fir:
> It is sad to say so but there is some real
> and terrible stupidnes in c99. When i wrote
> programs in c (and I am involved c user) I
> just use const int for array boundaries but
> in c99 (and some previous too, terribly) it
> will not compile (see for example
> http://stackoverflow.com/questions/1...-at-file-scope ) It is terribly wrong
> thing for ppl who just wants to use const int to this
> purposes and not to use preprocesor - as I do.
> It is terribly stupidness in my opinion, it have to
> be changed.


This is valid C++ code, thus one option would be just to switch to C++.
In C, however, const is probably not quite what you expect it to be.

 
Reply With Quote
 
 
 
 
SG
Guest
Posts: n/a
 
      11-18-2012
Am 18.11.2012 10:21, schrieb fir:
> It is sad to say so but there is some real
> and terrible stupidnes in c99. When i wrote
> programs in c (and I am involved c user) I
> just use const int for array boundaries but
> in c99 (and some previous too, terribly) it
> will not compile (see for example
> http://stackoverflow.com/questions/1712592/ ) It is terribly wrong
> thing for ppl who just wants to use const int to this
> purposes and not to use preprocesor - as I do.
> It is terribly stupidness in my opinion, it have to
> be changed.


To my knowledge this has been the way in C for ever. Are you complaining
about C99 not adopting the C++ style in treating a file-scope const
"variable" with a constant initializer as a constant [compile-time]
expression? Or are you suggesting that C90 handles this any better and
that C99 is actually a regression in this department?

In C++ you can actually do this and

const int foo = 10;

is implicitly static (file-scope) due to the top-level constness and foo
can be used as compile-time constant expression. This is by design
because B. Stroustrup doesn't like macros very much, either.

I sort of accepted this difference between C and C++. In C you just have
to #define something like this in order to be able to use it as the size
of a non-VL array. But I would appreciate it if this unnecessary
incompatibility went away...

 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      11-18-2012
W dniu niedziela, 18 listopada 2012 10:41:55 UTC+1 użytkownik SG napisał:
> Am 18.11.2012 10:21, schrieb fir:
>
> > It is sad to say so but there is some real

>
> > and terrible stupidnes in c99. When i wrote

>
> > programs in c (and I am involved c user) I

>
> > just use const int for array boundaries but

>
> > in c99 (and some previous too, terribly) it

>
> > will not compile (see for example

>
> > http://stackoverflow.com/questions/1712592/ ) It is terribly wrong

>
> > thing for ppl who just wants to use const int to this

>
> > purposes and not to use preprocesor - as I do.

>
> > It is terribly stupidness in my opinion, it have to

>
> > be changed.

>
>
>
> To my knowledge this has been the way in C for ever. Are you complaining
>
> about C99 not adopting the C++ style in treating a file-scope const
>
> "variable" with a constant initializer as a constant [compile-time]
>
> expression? Or are you suggesting that C90 handles this any better and
>
> that C99 is actually a regression in this department?
>
>
>
> In C++ you can actually do this and
>
>
>
> const int foo = 10;
>
>
>
> is implicitly static (file-scope) due to the top-level constness and foo
>
> can be used as compile-time constant expression. This is by design
>
> because B. Stroustrup doesn't like macros very much, either.
>
>
>
> I sort of accepted this difference between C and C++. In C you just have
>
> to #define something like this in order to be able to use it as the size
>
> of a non-VL array. But I would appreciate it if this unnecessary
>
> incompatibility went away...


yes, i know; i dislike #define and must to switch to c++ compatybility modeto compile
my besides that pure c codes

it is terrible, it should just change becouse
in other way though I am c (not c++) coder I must throw c compilers to trashbin - becouse
I dislike macros and do not use no one of them

c should just accept

const int table_max = 1000;
int table[table_max};

I do not know where this no 'const int array boundaries' dirty **** originates
but it seem to me that in older c there it was possible to use const ints as array boundaries, (not sure to this, usualy switched to c++ mode to resolve other old c troubles with int i before for loop and so :/ )

make c const int usable in c, call the comitee or compiler writers to include some switch :/





 
Reply With Quote
 
SG
Guest
Posts: n/a
 
      11-18-2012
Am 18.11.2012 11:02, schrieb fir:
> W dniu niedziela, 18 listopada 2012 10:41:55 UTC+1 użytkownik SG napisał:
>> Am 18.11.2012 10:21, schrieb fir:
>>
>>> It is sad to say so but there is some real
>>> and terrible stupidnes in c99. When i wrote
>>> programs in c (and I am involved c user) I
>>> just use const int for array boundaries but
>>> in c99 (and some previous too, terribly) it
>>> will not compile (see for example
>>> http://stackoverflow.com/questions/1712592/ )


[snip]

>> To my knowledge this has been the way in C for ever.


[snip]

>> of a non-VL array. But I would appreciate it if this unnecessary
>> incompatibility went away...

>
> yes, i know; i dislike #define and must to switch to c++ compatybility mode to compile
> my besides that pure c codes


[snip]

> c should just accept
>
> const int table_max = 1000;
> int table[table_max};
>
> I do not know where this no 'const int array boundaries' dirty **** originates
> but it seem to me that in older c there it was possible to use const ints as array boundaries, (not sure to this, usualy switched to c++ mode to resolve other old c troubles with int i before for loop and so :/ )


I don't think you're right. "older C" wasn't "better" in that respect.
 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      11-18-2012
>
>
> I don't think you're right. "older C" wasn't "better" in that respect.


ok
 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      11-18-2012
On Nov 18, 9:21*am, fir <profesor....@gmail.com> wrote:

> It is sad to say so but there is some real
> and terrible stupidnes in c99. When i wrote
> programs in c (and I am involved c user) I
> just use const int for array boundaries


no you didn't

> but
> in c99 (and some previous too, terribly)


all previous

> it
> will not compile (see for examplehttp://stackoverflow.com/questions/1712592/variably-modified-array-at...*) It is terribly wrong
> thing for ppl who just wants to use const int to this
> purposes and not to use preprocesor - as I do.
> It is terribly stupidness in my opinion, it have to
> be changed.




C changes pretty slowly so don't hold your breath

 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      11-18-2012
fir <> writes:
<snip>
> I do not know where this no 'const int array boundaries' dirty ****
> originates but it seem to me that in older c there it was possible to
> use const ints as array boundaries, (not sure to this, usualy switched
> to c++ mode to resolve other old c troubles with int i before for loop
> and so :/ )


It seems you've been writing C++ for some years now, so why not just be
a happy C++ programmer rather than an unhappy C one?

--
Ben.
 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      11-18-2012
W dniu niedziela, 18 listopada 2012 13:16:48 UTC+1 użytkownik Ben Bacarisse napisał:
> fir <> writes:
>
> <snip>
>
> > I do not know where this no 'const int array boundaries' dirty ****

>
> > originates but it seem to me that in older c there it was possible to

>
> > use const ints as array boundaries, (not sure to this, usualy switched

>
> > to c++ mode to resolve other old c troubles with int i before for loop

>
> > and so :/ )

>
>
>
> It seems you've been writing C++ for some years now, so why not just be
>
> a happy C++ programmer rather than an unhappy C one?
>


becouse i dislike all c++ features (and soul), and deply appreciate most ofc features (and its spirit), this

const int table_max = 100;
int table[table_max];

i consider as it should belong to c language also It should be, it is terrible that it fails here, (indeed i write in c but i change
to c++ becouse of some old c slight quirks
and was unaware that this terrible const int
boundary distaster is present here
 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      11-18-2012
fir <> writes:

You might want to look into using either the older Google groups
interface or a stand-alone news reader. The new Google groups seems to
mess up posts that go to Usenet very badly. (You might also consider
using your shift key.)

> W dniu niedziela, 18 listopada 2012 13:16:48 UTC+1 użytkownik Ben Bacarisse napisał:
>> fir <> writes:
>>
>> <snip>
>>
>> > I do not know where this no 'const int array boundaries' dirty ****

>>
>> > originates but it seem to me that in older c there it was possible to

>>
>> > use const ints as array boundaries, (not sure to this, usualy switched

>>
>> > to c++ mode to resolve other old c troubles with int i before for loop

>>
>> > and so :/ )

>>
>>
>>
>> It seems you've been writing C++ for some years now, so why not just be
>>
>> a happy C++ programmer rather than an unhappy C one?
>>

>
> becouse i dislike all c++ features (and soul), and deply appreciate
> most of c features (and its spirit),


You obviously don't dislike all C++ features since you want C to adopt
one of them!

> this
> const int table_max = 100;
> int table[table_max];


You don't *have* to use a macro. You can use an enum constant instead:

enum { table_max = 100 };
int table[table_max];

> i consider as it should belong to c language also It should be, it is
> terrible that it fails here, (indeed i write in c but i change to c++
> becouse of some old c slight quirks and was unaware that this terrible
> const int boundary distaster is present here


You have only two realistic options: keep using C++, or switch back to C
and use a macro or an enum. There is no hope at all that the C
committee will change the meaning of const any time soon. It's likely
to be 10 years before the next major revision of the language and even
then I don't think it's likely. If you want to try, posting here is
going to be of little use. You'll need a proposal and, probably,
backing from your national standards body.

BTW, I agree with you in theory: C should have used C++'s meaning of
const from the start, but back in the late 80s no one new that C++ would
become what it has, and C compilers were already using the more
restricted notion that became standard.

--
Ben.
 
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: Is this phase-accumulator trick well-known??? Mike Treseler VHDL 0 02-08-2009 07:17 PM
List mutation method gotcha - How well known? Hendrik van Rooyen Python 20 03-16-2008 09:55 AM
Difference between "library parts" of C99 and "language parts" of C99 albert.neu@gmail.com C Programming 3 03-31-2007 08:14 PM
C99 struct initialization (C99/gcc) jilerner@yahoo.com C Programming 3 02-20-2006 04:41 AM
well-known Internet sites which use Java based web servers Mladen Adamovic Java 3 10-24-2005 09:48 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57