Void foo() != void foo( void ) in C

(I dont know if this is outdated and of any significance but…) In C
function with no parameters list means “any parameters”:
http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Functions. In
C++ empty parameters list means “no parameters”. There are numerous function
declarations/definitions with empty parameters list in the SDL 1.3 source
tree.

If you find a function that fails in C++, then its significant. What
would the worse case scenario be anyways?
C++ compiler sees empty parameter list, but the SDL functions you’re
probably talking about doesn’t need parameters anyways so…
Programs should still build and run as usual.
I guess the question is, do we NEED to be explicit, to prevent some
unlikely abuse?

How bad is it? Did you see any void video(please place garbage here so
I can crash and burn functions) in your code review?

A potential rootkit through SDL would be something new and exciting,
that’s for sure.

Presenting SDL, the top tier, cross-platform rootkit distributor!
Don’t like what you see on people’s screens? SDL it!On Wed, Jun 16, 2010 at 1:53 AM, Stoiko Todorov <stoiko.todorov at gmail.com> wrote:

(I dont know if this is outdated and of any significance but…) In C
function with no parameters list means “any parameters”:
http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Functions. In
C++ empty parameters list means “no parameters”. There are numerous function
declarations/definitions with empty parameters list in the SDL 1.3 source
tree.


SDL mailing list,
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Uhm, you don’t need to be explicit. You only need to tell the compiler
what you want. f(void) means no args, f() means any args. If a
function doesn’t accept any, use (void). If it accepts anything, use f().

There’s nothing explicit here. “Explicit” is something that happens
anyway on its own, but you still write it down. f(void) isn’t something
that can happen on its own and you just want to be explicit about it.On 06/16/2010 06:30 PM, Jeremiah wrote:

On Wed, Jun 16, 2010 at 1:53 AM, Stoiko Todorov <stoiko.todorov at gmail.com> wrote:

(I dont know if this is outdated and of any significance but…) In C
function with no parameters list means “any parameters”:
http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Functions. In
C++ empty parameters list means “no parameters”. There are numerous function
declarations/definitions with empty parameters list in the SDL 1.3 source
tree.

If you find a function that fails in C++, then its significant. What
would the worse case scenario be anyways?
C++ compiler sees empty parameter list, but the SDL functions you’re
probably talking about doesn’t need parameters anyways so…
Programs should still build and run as usual.
I guess the question is, do we NEED to be explicit, to prevent some
unlikely abuse?

with foo() you say that it accepts anything, but without names you
can’t access any argument that you used
so what’s the point of making a foo() function in first place?On Wed, Jun 16, 2010 at 5:44 PM, Nikos Chantziaras wrote:

On 06/16/2010 06:30 PM, Jeremiah wrote:

On Wed, Jun 16, 2010 at 1:53 AM, Stoiko Todorov <stoiko.todorov at gmail.com> ?wrote:

(I dont know if this is outdated and of any significance but…) In C
function with no parameters list means “any parameters”:
http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Functions.
In
C++ empty parameters list means “no parameters”. There are numerous
function
declarations/definitions with empty parameters list in the SDL 1.3 source
tree.

If you find a function that fails in C++, then its significant. What
would the worse case scenario be anyways?
C++ compiler sees empty parameter list, but the SDL functions you’re
probably talking about doesn’t need parameters anyways so…
Programs should still build and run as usual.
I guess the question is, do we NEED to be explicit, to prevent some
unlikely abuse?

Uhm, you don’t need to be explicit. ?You only need to tell the compiler what
you want. ?f(void) means no args, f() means any args. ?If a function doesn’t
accept any, use (void). ?If it accepts anything, use f().

There’s nothing explicit here. ?“Explicit” is something that happens anyway
on its own, but you still write it down. ?f(void) isn’t something that can
happen on its own and you just want to be explicit about it.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

f(void) isn’t something that can
happen on its own and you just want to be explicit about it.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I understood some parts of what you said, but you lost me here.

Well I guess here too.On Wed, Jun 16, 2010 at 8:44 AM, Nikos Chantziaras wrote:

On Wed, Jun 16, 2010 at 8:44 AM, Nikos Chantziaras wrote:

Uhm, you don’t need to be explicit. You only need to tell the compiler what you want.

That is the definition of explicit isn’t it. Telling the compiler what I want?

Yes or No? - Does f(void) always happens automatically?

f(void) isn’t something that can
happen on its own and you just want to be explicit about it.

I understood some parts of what you said, but you lost me here.

Well I guess here too.

Uhm, you don’t need to be explicit. You only need to tell the compiler what you want.

That is the definition of explicit isn’t it. Telling the compiler what I want?

Yes or No? - Does f(void) always happens automatically?

No, a function can’t be make accepting (void) automatically.

As to what I meant with “explicit”, I had type casts in mind. This will
convert an unsigned int to a signed int:

unsigned u;
int s;
s = u;

However, you can also be explicit about it:

unsigned u;
int s;
s = (int)u;

This is what I was thinking when I read “I guess the question is, do we
NEED to be explicit”. This question assumed that f() and f(void) are
the same, but writing it as f(void) would be explicit about it. Which
it isn’t; f(void) is not an explicit way to write f().On 06/16/2010 06:55 PM, Jeremiah wrote:

On Wed, Jun 16, 2010 at 8:44 AM, Nikos Chantziaras wrote:
On Wed, Jun 16, 2010 at 8:44 AM, Nikos Chantziaras wrote:

The answer is “neglect” :slight_smile: When the functions were first coded, the
implementor didn’t have the f() vs f(void) thingy in his mind. So the
only question right now if what gain there is in converting them to
f(void). I’m not sure whether this would break binary compatibility
with existing applications. If yes, then I guess there’s no point in
doing it.On 06/16/2010 06:54 PM, Vittorio G. wrote:

with foo() you say that it accepts anything, but without names you
can’t access any argument that you used
so what’s the point of making a foo() function in first place?

On Wed, Jun 16, 2010 at 5:44 PM, Nikos Chantziaras wrote:

On 06/16/2010 06:30 PM, Jeremiah wrote:

On Wed, Jun 16, 2010 at 1:53 AM, Stoiko Todorov <stoiko.todorov at gmail.com> wrote:

(I dont know if this is outdated and of any significance but…) In C
function with no parameters list means “any parameters”:
http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Functions.
In
C++ empty parameters list means “no parameters”. There are numerous
function
declarations/definitions with empty parameters list in the SDL 1.3 source
tree.

If you find a function that fails in C++, then its significant. What
would the worse case scenario be anyways?
C++ compiler sees empty parameter list, but the SDL functions you’re
probably talking about doesn’t need parameters anyways so…
Programs should still build and run as usual.
I guess the question is, do we NEED to be explicit, to prevent some
unlikely abuse?

Uhm, you don’t need to be explicit. You only need to tell the compiler what
you want. f(void) means no args, f() means any args. If a function doesn’t
accept any, use (void). If it accepts anything, use f().

There’s nothing explicit here. “Explicit” is something that happens anyway
on its own, but you still write it down. f(void) isn’t something that can
happen on its own and you just want to be explicit about it.

The answer is “neglect” :slight_smile: When the functions were first coded, the
implementor didn’t have the f() vs f(void) thingy in his mind. So
the only question right now if what gain there is in converting them
to f(void).

With a function declaration of f(), code will work, but if a caller
accidentally calls with some (or any) arguments, they won’t get a
warning from the compiler. The aggravation of these kinds of errors
was why the f(void) syntax was introduced in C89.

I’m not sure whether this would break binary compatibility with
existing applications. If yes, then I guess there’s no point in
doing it.

Presumably SDL is still using C-linkage? If so, then there’s no binary
compatibility issue. Even if there was, though, it’s still worth
doing.

b

there should be no ABI difference between f() and f(void), so changing
all of them should be safe
-mikeOn Wed, Jun 16, 2010 at 3:00 PM, Nikos Chantziaras wrote:

The answer is “neglect” :slight_smile: ?When the functions were first coded, the
implementor didn’t have the f() vs f(void) thingy in his mind. ?So the only
question right now if what gain there is in converting them to f(void). ?I’m
not sure whether this would break binary compatibility with existing
applications. ?If yes, then I guess there’s no point in doing it.

I’ll go ahead and fix these. Do you already have a list of them?

Thanks!On Wed, Jun 16, 2010 at 1:53 AM, Stoiko Todorov <stoiko.todorov at gmail.com> wrote:

(I dont know if this is outdated and of any significance but…) In C
function with no parameters list means “any parameters”:
http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Functions. In
C++ empty parameters list means “no parameters”. There are numerous function
declarations/definitions with empty parameters list in the SDL 1.3 source
tree.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

I’ll go ahead and fix these. Do you already have a list of them?

Thanks!

(I dont know if this is outdated and of any significance but…) In C
function with no parameters list means “any parameters”:
http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Functions.
In
C++ empty parameters list means “no parameters”. There are numerous
function
declarations/definitions with empty parameters list in the SDL 1.3 source
tree.

Under gcc, I think the compiler warning flag you want is -Wmissing-prototypes.

FYI, I had a blog entry that talks a little bit about the origins of
this. Warning: it was a rant in in the context of C++ being brain-dead
and breaking on typedefs when combined with proper C prototypes.

http://playcontrol.net/ewing/jibberjabber/another_c_vs_c_incompatibil.htmlOn 6/17/10, Sam Lantinga wrote:

On Wed, Jun 16, 2010 at 1:53 AM, Stoiko Todorov <stoiko.todorov at gmail.com> wrote:

Whilst this diccussion is technically valid for C, I do hope people realise
this use has been discouraged since C99 (see 6.11.6). If the next version
removes this feature then all changes will need to be reverted or two
parallel versions kept ie c99 and post c0x/c1x

Liam

Are people really concerned about C99?On Thu, Jun 17, 2010 at 5:16 PM, liam mail <liam.list at googlemail.com> wrote:

Whilst this diccussion is technically valid for C, I do hope people realise
this use has been discouraged since C99 (see 6.11.6). If the next version
removes this feature then all changes will need to be reverted or two
parallel versions kept ie c99 and post c0x/c1x

Liam


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Depends who you talk to.

Microsoft says that they don’t improve their C99 support because most
Windows developers that they interview about the subject say that C89 is
good enough and most of the development is now done in C++.

Speaking from my experience that is the way in most IT projects I have been
involved. Many developers are not even aware that C99 exists.

And to be honest that is not to wonder. The official C language book has not
been updated for C99, there are hardly new books about C, and the ones that
every now and then come out, only briefly mention some of the C99 features.–
Paulo

On Fri, Jun 18, 2010 at 4:08 AM, Jeremiah wrote:

Are people really concerned about C99?

On Thu, Jun 17, 2010 at 5:16 PM, liam mail <liam.list at googlemail.com> wrote:

Whilst this diccussion is technically valid for C, I do hope people
realise
this use has been discouraged since C99 (see 6.11.6). If the next version
removes this feature then all changes will need to be reverted or two
parallel versions kept ie c99 and post c0x/c1x

Liam


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

This is because of legacy reasons.

In the old days there was no void, and a function could take any amount of
parameters without
checking for them.

The standard just adopted the common practice among existing compilers.

C++ being a better C (open to discussion), made an empty parameter list the
same as void.–
Paulo

On Fri, Jun 18, 2010 at 1:41 AM, Eric Wing wrote:

On 6/17/10, Sam Lantinga wrote:

I’ll go ahead and fix these. Do you already have a list of them?

Thanks!

On Wed, Jun 16, 2010 at 1:53 AM, Stoiko Todorov <stoiko.todorov at gmail.com> wrote:

(I dont know if this is outdated and of any significance but…) In C
function with no parameters list means “any parameters”:

http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Functions.

In
C++ empty parameters list means “no parameters”. There are numerous
function
declarations/definitions with empty parameters list in the SDL 1.3
source

tree.

Under gcc, I think the compiler warning flag you want is
-Wmissing-prototypes.

FYI, I had a blog entry that talks a little bit about the origins of
this. Warning: it was a rant in in the context of C++ being brain-dead
and breaking on typedefs when combined with proper C prototypes.

http://playcontrol.net/ewing/jibberjabber/another_c_vs_c_incompatibil.html


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Here are some (all?) found in the header files. There are many many more in
the .c files.
char *alloca();
extern void hiddi_enable_mouse();
extern void hiddi_disable_mouse();
extern int RISCOS_InitTask();
extern void RISCOS_ExitTask();
extern int RISCOS_GetWimpVersion();
extern int RISCOS_GetTaskHandle();
extern void RISCOS_StoreWimpMode();
extern void RISCOS_RestoreWimpMode();
typedef int (*PFNGXCloseDisplay) ();
typedef void *(*PFNGXBeginDraw) ();
typedef int (*PFNGXEndDraw) ();
typedef int (*PFNGXOpenInput) ();
typedef int (*PFNGXCloseInput) ();
typedef int (*PFNGXSuspend) ();
typedef int (*PFNGXResume) ();
extern SDL_bool X11_UseDirectColorVisuals();On Thu, Jun 17, 2010 at 7:47 PM, Sam Lantinga wrote:

I’ll go ahead and fix these. Do you already have a list of them?

Thanks!

On Wed, Jun 16, 2010 at 1:53 AM, Stoiko Todorov <@Stoiko_Todorov> wrote:

(I dont know if this is outdated and of any significance but…) In C
function with no parameters list means “any parameters”:
http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Functions.
In
C++ empty parameters list means “no parameters”. There are numerous
function
declarations/definitions with empty parameters list in the SDL 1.3 source
tree.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

one more…

extern jmp_buf *jump_env();

If I interpret both you and 6.11.6 correctly, then I don’t see why we
would need to revert. C only discourages empty parameter lists to mean
any parameter. SDL doesn’t use this feature at all as far as I know.
(I don’t know semi-modern code base that does.) As far as I can tell,
explicit void to denote no parameters is here to stay.On 6/17/10, liam mail <liam.list at googlemail.com> wrote:

Whilst this diccussion is technically valid for C, I do hope people realise
this use has been discouraged since C99 (see 6.11.6). If the next version
removes this feature then all changes will need to be reverted or two
parallel versions kept ie c99 and post c0x/c1x

C99 is becoming increasingly important on OS X (Mac, iOS). Since
Objective-C is supposed to be a true superset of C (unlike C++), it
inherits everything from C. And since Apple is basically writing a new
compiler from scratch (llvm, clang), it is of great benefit to them to
just implement C99 and then Objective-C on top of that instead of
writing their own extension loaded C compiler and then Obj-C on top of
both (though granted they have to do that anyway to support Blocks,
but the less work the better). I think C99 is now the default C mode
in Xcode.On 6/17/10, Jeremiah wrote:

Are people really concerned about C99?

Thanks, I fixed a bunch of warnings that popped up with -Wmissing-prototypesOn Thu, Jun 17, 2010 at 4:41 PM, Eric Wing wrote:

On 6/17/10, Sam Lantinga <@slouken> wrote:

I’ll go ahead and fix these. ?Do you already have a list of them?

Thanks!

On Wed, Jun 16, 2010 at 1:53 AM, Stoiko Todorov <stoiko.todorov at gmail.com> wrote:

(I dont know if this is outdated and of any significance but…) In C
function with no parameters list means “any parameters”:
http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Functions.
In
C++ empty parameters list means “no parameters”. There are numerous
function
declarations/definitions with empty parameters list in the SDL 1.3 source
tree.

Under gcc, I think the compiler warning flag you want is -Wmissing-prototypes.

FYI, I had a blog entry that talks a little bit about the origins of
this. Warning: it was a rant in in the context of C++ being brain-dead
and breaking on typedefs when combined with proper C prototypes.

http://playcontrol.net/ewing/jibberjabber/another_c_vs_c_incompatibil.html


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC