On 2012-07-18 22:12, Walter Bright wrote:
How would you get the arguments inside foo?
I don't know, you're the compiler writer :) I don't know these kind of
things, that's why I started this thread. I'm just telling you how
GCC/Clang treats these code snippets.
--
/Jacob Carlborg
On Wednesday, 18 July 2012 at 20:13:10 UTC, Walter Bright wrote:
On 7/18/2012 11:47 AM, Jacob Carlborg wrote:
On 2012-07-18 20:43, Walter Bright wrote:
On 7/18/2012 4:59 AM, Jacob Carlborg wrote:
Does that mean that this C++ declaration:
void foo (...);
Not allowed in C or C++.
When
On Thu, 19 Jul 2012 08:33:12 +0100, Paulo Pinto pj...@progtools.org
wrote:
On Wednesday, 18 July 2012 at 20:13:10 UTC, Walter Bright wrote:
On 7/18/2012 11:47 AM, Jacob Carlborg wrote:
On 2012-07-18 20:43, Walter Bright wrote:
On 7/18/2012 4:59 AM, Jacob Carlborg wrote:
Does that mean
On 2012-07-19 11:38, Regan Heath wrote:
asn't ware that was valid ANSI C, perhaps it's a GCC/clang
feature? Can anyone find docs on it?
Note that it only works when compiling as C++. Perhaps it works like this:
If C++ is interpreting this:
void foo ();
As:
void foo (void);
Perhaps it
On Tuesday, 17 July 2012 at 18:37:54 UTC, H. S. Teoh wrote:
I guess you predate me. ;-) When I started learning C, it was
already in
the ANSI syntax, though there were enough KR style code
floating around
that I've at least _seen_ KR syntax. I'm guessing nowadays
most people
don't even know
On 7/16/2012 11:56 PM, Jacob Carlborg wrote:
To my understanding this is legal C :
int foo ();
It's a KR-style variadic functions, while their use is discouraged, they're
still legal C.
Variadic functions, in order to work in C, need at least one parameter so that
varargs can work.
int
On Tue, 17 Jul 2012 20:31:19 +0100, Jacob Carlborg d...@me.com wrote:
On 2012-07-17 17:11, Regan Heath wrote:
Ahh, I've been looking at the ANSI C spec and assuming that is what
you're basing things off, KR C was pre-ANSI C and may have different
rules. I think you should probably aim to be
On Tue, 17 Jul 2012 19:39:25 +0100, H. S. Teoh hst...@quickfur.ath.cx
wrote:
On Tue, Jul 17, 2012 at 08:07:08PM +0200, Paulo Pinto wrote:
On Tuesday, 17 July 2012 at 15:16:56 UTC, Regan Heath wrote:
[...]
So all KR function declarations were name() with no parameters.
R
KR was more than
In any case. It think the practical solution to this problem is to assume
you're working with modern code, and have a command line option to make it
assume KR or old-style declarations.
In the old-style mode you would have to assume a function with an empty ()
could have any number of
On Tue, 17 Jul 2012 20:42:09 +0100, Jacob Carlborg d...@me.com wrote:
On 2012-07-17 17:13, Regan Heath wrote:
Is Clang open source, can we see the code for that function? Perhaps
it's a bug.. ANSI C may have made () without void obsolete, but no
compiler I've ever used has actually enforced
On 2012-07-18 12:25, Regan Heath wrote:
In any case. It think the practical solution to this problem is to
assume you're working with modern code, and have a command line option
to make it assume KR or old-style declarations.
In the old-style mode you would have to assume a function with an
On 2012-07-18 11:41, Walter Bright wrote:
Variadic functions, in order to work in C, need at least one parameter
so that varargs can work.
int foo();
declares a function with an unspecified parameter list, not a variadic
one. It is specified by a definition somewhere:
int foo(a,b)
On Wed, Jul 18, 2012 at 11:23:33AM +0100, Regan Heath wrote:
On Tue, 17 Jul 2012 19:39:25 +0100, H. S. Teoh
hst...@quickfur.ath.cx wrote:
[...]
This modern C declaration:
int main(int argc, char **argv) {
exit(1);
}
is written thus in KR:
int main(argc,
On 7/18/2012 4:59 AM, Jacob Carlborg wrote:
Does that mean that this C++ declaration:
void foo (...);
Not allowed in C or C++.
Is the same as this C declaration?
void foo ();
That is void foo(void) in C++.
On 2012-07-18 20:43, Walter Bright wrote:
On 7/18/2012 4:59 AM, Jacob Carlborg wrote:
Does that mean that this C++ declaration:
void foo (...);
Not allowed in C or C++.
When compiling in C++ mode, both Clang and GCC accepts this.
Is the same as this C declaration?
void foo ();
That is
On 7/18/2012 11:47 AM, Jacob Carlborg wrote:
On 2012-07-18 20:43, Walter Bright wrote:
On 7/18/2012 4:59 AM, Jacob Carlborg wrote:
Does that mean that this C++ declaration:
void foo (...);
Not allowed in C or C++.
When compiling in C++ mode, both Clang and GCC accepts this.
How would
To my understanding this is legal C :
int foo ();
It's a KR-style variadic functions, while their use is discouraged,
they're still legal C.
If I, in D, declare a variadic function with C linkage that doesn't
take, at least, one regular parameter the compiler will complain.
extern (C) int
On Tuesday, 17 July 2012 at 06:56:17 UTC, Jacob Carlborg wrote:
To my understanding this is legal C :
int foo ();
It's a KR-style variadic functions, while their use is
discouraged, they're still legal C.
My eyes!! They're bleeding!!
On Tuesday, 17 July 2012 at 07:06:38 UTC, Mehrdad wrote:
On Tuesday, 17 July 2012 at 06:56:17 UTC, Jacob Carlborg wrote:
To my understanding this is legal C :
int foo ();
It's a KR-style variadic functions, while their use is
discouraged, they're still legal C.
My eyes!! They're bleeding
On 2012-07-17 09:06, Mehrdad wrote:
My eyes!! They're bleeding!!
First I wanted to know if my interpretation is correct and then I was
trying to figure out how my tool should behave if it encounters a
function like this.
--
/Jacob Carlborg
On Tue, 17 Jul 2012 12:43:46 +0100, Jacob Carlborg d...@me.com wrote:
On 2012-07-17 09:06, Mehrdad wrote:
My eyes!! They're bleeding!!
First I wanted to know if my interpretation is correct and then I was
trying to figure out how my tool should behave if it encounters a
function like
On Tue, 17 Jul 2012 13:32:08 +0100, Regan Heath re...@netmail.co.nz
wrote:
On Tue, 17 Jul 2012 12:43:46 +0100, Jacob Carlborg d...@me.com wrote:
On 2012-07-17 09:06, Mehrdad wrote:
My eyes!! They're bleeding!!
First I wanted to know if my interpretation is correct and then I was
On 2012-07-17 14:32, Regan Heath wrote:
After a bit of googling and a test with my local MSVC9 I think old-style
variadics look like this:
#include varargs.h
#include stdio.h
void foo(va_alist)
va_dcl
{
va_list p;
va_start(p);
vprintf(%d %d %d\n, p);
}
void main()
{
On 2012-07-17 15:05, Regan Heath wrote:
In my specific case I could add int a as the first parameter, and all
was well. Each case will be different, and it's conceivable there is a
C old-style variadic which takes /any/ type of first parameter, which
could be a problem, however the key issue
On Tue, 17 Jul 2012 15:01:02 +0100, Jacob Carlborg d...@me.com wrote:
On 2012-07-17 15:05, Regan Heath wrote:
In my specific case I could add int a as the first parameter, and all
was well. Each case will be different, and it's conceivable there is a
C old-style variadic which takes /any/
On Tue, 17 Jul 2012 15:02:44 +0100, Jacob Carlborg d...@me.com wrote:
On 2012-07-17 14:32, Regan Heath wrote:
After a bit of googling and a test with my local MSVC9 I think old-style
variadics look like this:
#include varargs.h
#include stdio.h
void foo(va_alist)
va_dcl
{
va_list
On 2012-07-17 16:36, Regan Heath wrote:
I believe old-style no parameter function declarations MUST have void
i.e.
int foo(void);
That is still the case, regardless of style?
They cannot read:
int foo();
The latter MUST have parameters, we just can't tell what they are.
Take
On 2012-07-17 16:37, Regan Heath wrote:
All my googling for old style variadic etc returned the use of
va_alist and va_dcl so I can't see where/why Clang would do what it's
doing.
To be accurate it's the libclang function clang_isFunctionTypeVariadic
that returns true.
On 17/07/2012 08:56, Jacob Carlborg wrote:
To my understanding this is legal C :
int foo ();
It's a KR-style variadic functions, while their use is discouraged,
they're still legal C.
If I, in D, declare a variadic function with C linkage that doesn't
take, at least, one regular parameter
On Tue, 17 Jul 2012 15:46:34 +0100, Jacob Carlborg d...@me.com wrote:
On 2012-07-17 16:36, Regan Heath wrote:
I believe old-style no parameter function declarations MUST have void
i.e.
int foo(void);
That is still the case, regardless of style?
They cannot read:
int foo();
On Tue, 17 Jul 2012 15:50:27 +0100, Jacob Carlborg d...@me.com wrote:
On 2012-07-17 16:37, Regan Heath wrote:
All my googling for old style variadic etc returned the use of
va_alist and va_dcl so I can't see where/why Clang would do what it's
doing.
To be accurate it's the libclang function
On Tue, 17 Jul 2012 15:46:34 +0100, Jacob Carlborg d...@me.com wrote:
On 2012-07-17 16:36, Regan Heath wrote:
I believe old-style no parameter function declarations MUST have void
i.e.
int foo(void);
That is still the case, regardless of style?
They cannot read:
int foo();
deadalnix deadal...@gmail.com wrote in message
news:ju3uqc$55g$1...@digitalmars.com...
It is used in testfptr.d from dmd's testsuite.
No, that's a D-linkage variadic.
On Tuesday, 17 July 2012 at 15:16:56 UTC, Regan Heath wrote:
On Tue, 17 Jul 2012 15:46:34 +0100, Jacob Carlborg
d...@me.com wrote:
On 2012-07-17 16:36, Regan Heath wrote:
I believe old-style no parameter function declarations MUST
have void
i.e.
int foo(void);
That is still the
On Tuesday, 17 July 2012 at 15:13:52 UTC, Regan Heath wrote:
On Tue, 17 Jul 2012 15:50:27 +0100, Jacob Carlborg
d...@me.com wrote:
On 2012-07-17 16:37, Regan Heath wrote:
All my googling for old style variadic etc returned the
use of
va_alist and va_dcl so I can't see where/why Clang would
On Tue, Jul 17, 2012 at 08:07:08PM +0200, Paulo Pinto wrote:
On Tuesday, 17 July 2012 at 15:16:56 UTC, Regan Heath wrote:
[...]
So all KR function declarations were name() with no parameters.
R
KR was more than that.
This modern C declaration:
int main(int argc, char **argv) {
On 2012-07-17 17:11, Regan Heath wrote:
Ahh, I've been looking at the ANSI C spec and assuming that is what
you're basing things off, KR C was pre-ANSI C and may have different
rules. I think you should probably aim to be ANSI C compliant and
above, and ignore KR.
This page says otherwise:
On 2012-07-17 17:13, Regan Heath wrote:
Is Clang open source, can we see the code for that function? Perhaps
it's a bug.. ANSI C may have made () without void obsolete, but no
compiler I've ever used has actually enforced that - or perhaps C++ made
old-style function definition/declarations
I was sure that if function is declared with empty () than you
can call it with any arguments you imagine, as it is in following
examples.
= ex. 1
* cat main.c
void a() {
}
int main()
{
a(1, 2, 3);
return 0;
}
* gcc -Wall -Wextra -pedantic main.c
*
Definitely - I live in a very technologically-savvy dorm in college, and
when I encountered it for the first time nobody there had any idea what
it was.
...we did later find an old book in our library that had it, though.
-Matt
On 07/17/2012 02:39 PM, H. S. Teoh wrote:
On Tue, Jul 17, 2012
40 matches
Mail list logo