Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Found something cool in C11

Name: Anonymous 2014-08-06 10:58

c.h
typedef int i;
extern int shi;


c.c
#include "c.h"
#include "c.h"
#include "c.h"

int shi;

int
main (void)
{
return 0;
}


As you can see C11 allows multiple typedefs of the same type to the same type, a typedef long i; would be illegal
This avoids the need for include guards but sadly it does not work for structs, not that this is a problem

Name: Anonymous 2014-08-06 11:04

Already implemented in Haskell.

Name: Anonymous 2014-08-06 11:25

Cool but I don't think header guards were ever a problem. Plus, a correctly laid out project doesn't need compile guards.

Name: Anonymous 2014-08-06 11:26

>>1
But even ANSI C (1990) allows this

Name: Anonymous 2014-08-06 11:35

>>4
It does not

Name: Anonymous 2014-08-06 11:47

>>5
This is perfectly legal in c90:

typedef int a;
typedef int a;

int b;
int b;

int main(){return 0;}

Name: Anonymous 2014-08-06 11:53

>>6
I dupt it, can you prove it?
Or you think that just because GCC does not generate a error? (tip: try with -pedantic)

int b;
int b;
This is not legal at all

Name: Anonymous 2014-08-06 11:56

>>7
It is, read the standard, it says that multiples declarations in the file scope (which implies multiples tentatives definitions) are ok.

Also, you can set what standard you wanna use in gcc.

Name: Anonymous 2014-08-06 12:50

include guards
Just put `pragma once` in the beginning

Name: Anonymous 2014-08-06 12:59

>>8
I take it back, you are right about this but the typedef thing is different, see 6.2.2:6 in C99 and 6.7:3
In C11 they add in 6.7:3 this:
except that:
— a typedef name may be redefined to denote the same type as it currently does, provided that type is not a variably modified type;

Name: Anonymous 2014-08-06 13:04

So C retards haven't even figured out how to import modules yet?

Name: Anonymous 2014-08-06 15:13

>>1
Yes we have.

#include "module.c"

Name: Anonymous 2014-08-06 16:27

>>11
Afair, Apple wanted to standardize them. But it's just never really been an issue I guess.

Name: Anonymous 2014-08-06 16:30

>>10
Ok I'm a bit confused now: in gcc when you specify the standard to C90 you get no warnings nor errors BUT in clang it says that that is a C11-only feature. I'm still not convinced as (quoting from the ISO C90) "a typedef name shares the same name space as other identifiers declared in ordinary declarators", so I interpret this implies that a typedef name also shares the same rules for redeclaration of object in the file scope (6.7.2).
Check out this:
typedef int a;
main(){
typedef char a;
return 0;
}

This is ok even with clang. It's not the same thing but it shows how a typedef name identifier is similar to an object identifier.

Maybe the new addition in C11 6.7.3 is just a clarification.

Name: Anonymous 2014-08-06 17:35

C11 is objectively inferior to C89. There is no 10th rule for huskel or any other language. Lisp has it all!

Name: Anonymous 2014-08-06 17:38

>>15
Hate to break it to you, but the "10th rule of Greenspun" isn't really a rule, but wishful thinking of LISHP idiots who couldn't bear seeing their brainchild being forgotten and deserted.

Name: Anonymous 2014-08-06 17:39

>>16
Can you explain why a Lisp with Haskells features can not exist? Because I don't understand what is so special about Haskells syntax that you can't have a lisp with its features.

Name: Anonymous 2014-08-06 17:40

>>14
GCC is shit with the default warrnings, use --std=c90 and -pedantic
In that case it will show the error

Error: Post less often
I just got the IP you TURD!

Name: Anonymous 2014-08-06 18:24

in gcc when you specify the standard to C90
>>18
As I said I did use -ansi. With pedantic it gives you a warning (not error) for redefining the identifier.
I'm using gcc 4.9 and clang 3.4.1.

Name: Anonymous 2014-08-06 19:20

>>19
pedantic never gives errors

Name: Anonymous 2014-08-07 5:04

>>17
It can exist, but it will never exist. LITHP is subject to the "could be done but never will be" curse.

Name: Anonymous 2014-08-07 19:18

hax my feature

Name: Anonymous 2016-10-24 14:58

>>12
Automated copy-and-paste does not count as module inclusion.

Name: Anonymous 2017-01-05 18:33

>>9
Pragma once isn't strictly conforming.

>>16
``Greenspun's Tenth Rule" is actually Greenspun's First Observation.

>>17
Haskal is just Lisp reimplemented by academics who for some reason want a language whose syntax is somewhere between perl and sepples in readability.

Name: Anonymous 2017-01-05 19:02

>>15-17,21,24
Greenspun's 10th is called ``the web browser'' also known as EichLisp.

Name: Anonymous 2017-01-06 14:17

>>24
Lisp is design for list processing. Haskell syntax is inspired after the syntax of written mathematics.

Name: Alyssa P. Hacker 2017-01-06 14:34

#pragma once

Name: Anonymous 2017-01-06 17:05

>>27
#pragma once is non-standard.

Name: Anonymous 2017-01-06 17:16

>>28
Its a standard for every decent compiler. If a compiler doesn't have it, why you would trust it with your code? If a closed source/proprietary junk doesn't have #pragma once,its compiler company problem. Guess they could of paid programmers more, instead of selling junk electronics with crippled compilers.

Name: Anonymous 2017-01-09 20:37

That's INTERCAL bullshit.

Name: Anonymous 2017-02-25 23:27

>>29
Then why don't they make it part of DA STANDARD?

Name: Anonymous 2017-02-26 0:20

check 'em

Name: Steve 2017-02-26 2:44

>>32
no me

Name: Anonymous 2017-02-26 2:50

This thread has been pruned or deleted.

Name: Anonymous 2017-02-26 3:32

PRUNE MY ANUS

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List