Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Bartc <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Labels |
| Date | 2015-08-17 11:04 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <mqsbgh$bs0$1@dont-email.me> (permalink) |
| References | (2 earlier) <874mk0goix.fsf@bsb.me.uk> <mqokd9$qv5$1@dont-email.me> <ln4mk09e0k.fsf@kst-u.example.com> <mqplbf$ipu$1@dont-email.me> <c7547393-536e-4169-87e9-bf4fa5fc4c49@googlegroups.com> |
On 17/08/2015 04:42, David Kleinecke wrote:
> On Sunday, August 16, 2015 at 2:34:31 AM UTC-7, Bart wrote:
>> On 16/08/2015 03:13, Keith Thompson wrote:
>>> Bartc <bc@freeuk.com> writes:
>>> [...]
>>>> But even knowing a starter symbol is a typedef name, then with 'T(' you
>>>> might still be a long way from knowing if this is a simple variable
>>>> declaration, or the start of a 1000-line function definition.
>>>
>>> At block scope, function definitions are not permitted. At file scope,
>>> a function definition cannot start with 'T('; it requires at least a
>>> type name and an identifier.
>>
>> The following seems to be legal:
>>
>> #include <stdio.h>
>>
>> typedef int T;
>>
>> T(main)(void) {
>> printf("Hello World\n");
>> }
>>
>> --
>> Bartc
>
> It is my understanding that typedefs are not actual types but rather
> a kind of alsias for the type they are defined as. Hence
> typedef int T;
> makes
> T main ....
> compile eactly as if you had written
> int main ...
Possibly you're confusing the typedef T with a macro T. The translation
from T to int can't be done automatically because it first has to be
established exactly what T is at the point it is encountered.
It could be one of:
* A label name T:
* A function name T(10);
* A variable name T+U;
* An enum name T;
* A different typedef name
* Or the int typedef as defined above
> The compiler must maintain internally a table of what typedef names
> mean. The meaning part of that table is a (possibly very complicated)
> expression in non-typedef types and their decoration.
No more complicated than what is stored with each variable or parameter
name. The difficulty here is (1) determining that this must be a typedef
name; (2) finding out which typedef if there are several possibilities.
(The language I normally compile has a far simpler syntax to make life
easier. At any point where a declaration might be expected, then if
'<name> <name>...' is encountered, the first name is assumed to be a
user type name. Then I just have to determine which type.
Even here, I have it easy because I only have one possible scope in each
function, while C could potentially have hundreds, one per block, each
containing a different version of 'typedef <type> T;'.)
--
Bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 09:46 -0700
Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-15 14:49 -0400
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 18:48 -0700
Re: Labels Bartc <bc@freeuk.com> - 2015-08-15 18:27 +0100
Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-15 23:44 +0100
Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-15 19:04 -0400
Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-16 00:47 +0100
Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-15 20:20 -0400
Re: Labels Bartc <bc@freeuk.com> - 2015-08-16 01:56 +0100
Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-15 19:47 -0700
Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-16 11:59 -0400
Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-16 22:42 +0100
Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-16 20:39 -0400
Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-17 03:16 +0100
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 19:01 -0700
Re: Labels Bartc <bc@freeuk.com> - 2015-08-16 01:11 +0100
Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-15 19:13 -0700
Re: Labels Bartc <bc@freeuk.com> - 2015-08-16 10:34 +0100
Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-16 13:58 -0700
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-16 20:42 -0700
Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-16 21:24 -0700
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-17 18:01 -0700
Re: Labels Bartc <bc@freeuk.com> - 2015-08-17 11:04 +0100
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 19:04 -0700
Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-16 23:55 +0100
Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 19:00 -0700
csiph-web