Your void main is a system-specific way of writing the startup function which may or may not work. The C language requires (hosted) implementations to support int main(void) and int main(int, char **). Also, the printf function must be declared before being used. This is because it is variadic. Implicit declarations are not required to be compatible with variadic functions, so this may or may not work. If you fix these problems, then the program outputs 2 (in a reliable way that should work everywhere). The expression x=2 yields the new value of x. The printf function operates on the value produced by the argument expression, not on the object x. (I.e. the new value of x is stable before the function is called, due to a sequence point that happens before a function call, but that is irrelevant since printf does not know anything about x.)
Name:
Anonymous2012-01-19 12:40
>>7
Oh shit main. Are you the same Kaz whose C expection handling code that got used in wireshark?! Because based on how you write, I'm don't think you're posing as him.
Name:
Anonymous2012-01-19 12:43
>>7
Yeah, I think you are the same person! Wow, I've gone back and forth with you on another programming forum. You're a programming god.
>>15
Not a mental midget to kodak.
Guy must be the second coming of Dennis Ritchie & McCarthy >>7
Put actual email in the email field, must be crazy or trolling.
Name:
Anonymous2012-01-19 13:43
easy guide to detecting faggots:
1. utter "sizeof(char) is always 8 on proper architectures"
2. see if they cringe
3. (optionally) if they do, punch them in the groins
Name:
Anonymous2012-01-19 13:45
>>17
Now tell us again why you can't get a programming job.
Name:
172012-01-19 13:48
self-fix:
1. utter "((char)1<<8 + (char)1<<7) == 1<<7 on all proper architectures"
>>20
8 is ambiguous. Man, I tell ya, your written communication is almost as bad as your programming skills. So again, you're stupid. And yet again, you have no possible future as a computer programmer.
Name:
Anonymous2012-01-19 13:56
I bet kodak is the kind of faggot who respects strict aliasing everywhere.
>>20
Also, once again, you need to learn how to read. Look at how ANSI/ISO C9899 defines char. Do you see 8 anywhere? Does the standard imply 8? Exactly. Now shut your pie hole you mental midget.
Name:
Anonymous2012-01-19 14:00
>>24
I don't, but on all proper (ie non-shit) architectures it will be 8 bits. Fuck your microcontrollers, faggot.
>>24
Me thinks the standard guarantees sizeof(char) is 1, hence you failed to get the hint.
Hugs & kisses.
Name:
Anonymous2012-01-19 14:02
>>23
That kind of reminds me of a firm that I interviewed with right after undergrad school. The managers not only asked me to solve the programming problems, but solve them in such a way that it would have to pass a compiler with all of the warnings enabled.
>>26
It defines it as 1 (byte). Nowhere does it say anything about it being 8 bits. There is a reason for being so subtle. In some respects, it's kind of like how '%' in java isn't modulo. The difference is subtle, but important.
>>25
In other words, you expect the shit to only run on your mothers PC. Nice job chief. You're below average.
Name:
Anonymous2012-01-19 14:10
>>28
What he's saying is that sizeof(char) is always 1, which defeats your little "[code]sizeof(char)[/code
is always 8 on proper architectures" impression.
>>25,27
C is not meant to be a general-purpose algorithmic language. People trying to use it as such is the reason why we have so much shit software today and so many security flaws. Just look at GNOME or the Linux kernel. I'm not saying C++ is any better, of course, it just amplifies C's problem by piling layers and layers of shit on top of it.
So please, use C as what it was meant to be; a portable assembly language.
>>25
Enjoy your unreliability and lack of GC. I truly hope you get stuck designing GUIs in C for the rest of your shitty life.
>>32
The last post I saw from his on comp.lang.c was the source code to emulating the whole try/catch thing. He went on to say something to the effect that this code eventually made its way into wirehark. I also remember him talking about working on some kind of embedded linux thing.
I smell bullshit. The reason why GNOME is crap is because the homos on that project decided to do an entire code rewrite instead of fixing the existing bugs. This is because, as you probably don't know, it's just far easier to rewrite the crap and "get it right this time".
>>36
Here's what's really funny about shit like GNOME. It used to be that part of the code base was stable and secure. Then a new group of wankers came in and just rewrote it. This is because, and I quote the one engineer "The code looks ugly, and besides, I really don't understand what it does".
>>25'
>2012
>using 8-bit bytes for obsolete 8-bit character sets
WE UNICODE NOW
Name:
Anonymous2012-01-19 14:45
>>38'
>2012
>using unicode
ANSI master race here, suck my dick mental midget toilet scrubber. You will never amount to anything in your life and I have to keep coming on /prog/ and making fun of you mental midgets to keep my unstable self-esteem from hitting rock bottom.
>>36`
>implying`we'll get it right this time' ever works
atleast they have sexier sugar coated code now, so maybe someone moar capable will be able to understand their bullshit without reading 10000+ pages of homo bs
Hosted is a word that refers to C implementations that have a full library (the opposite is "freestanding"). In freestanding C, there may not be a supported startup function called main, and there is no standard in this are. For instance, the Linux kernel does not start with int main(int argc, char **argv). It uses gcc as a freestanding implementation (no standard library either, just pieces of it the kernel provides for itself). Hosted C implementations can support additional ways for writing the startup function beside the standard one. (E.g. Windows has WinMain).
void main(void) is "bad" because it is a poor tradeoff. you're leaving the standard dialect of C, without getting anything in return (and void is one letter more than int so you don't even save typing). The only exception would be that you need to program some system which for some reason only accepts void main.
void main is cluelessly used by programmers without checking that it is supported on systems where it isn't actually documented as a valid startup function. it just works by fluke, and usually leaves the program with a garbage termination status, too, if the program stops by running off the end of main instead of calling exit.
>>36-37
While I agree that the current GNOME developers may be likened to a bunch of smoking cigarettes, my statement is stronger; I am stating that the root of the problem is the language itself. You don't see people writing HTML engines in assembly -- "of course not, that would be error prone (therefore possibly introducing security flaws) and rather masochistic". Then why do you see people writing such complex things in a language that is merely one thin layer of abstraction over assembly language?
Nay, C was meant to be portable assembly, and it was meant to be used for small programs like bootloaders or parts of OS kernels. And in this context, it's a bit hard to assume that chars don't have a certain size, or to respect strict aliasing given the crazy amount of casts that are to be done.
Oh and don't bother arguing that C is defined in terms of the C abstract machine and therefore has no relationship with assembly. The reason C is so useful is exactly because its popular implementations interface and integrate so well with assembly code and with the underlying machine, thereby yielding very efficient code. A C implementation that would just stick to the letter of the standard and specify nor allow anything else would be quite very pointless. C is not a great language. It's really the compilers that make it worth it.
"Use of an uninitialized variable: This is commonly known as source of problems in C programs and there are many tools to catch these: from compiler warnings to static and dynamic analyzers. This improves performance by not requiring that all variables be zero initialized when they come into scope (as Java does). For most scalar variables, this would cause little overhead, but stack arrays and malloc'd memory would incur a memset of the storage, which could be quite costly, particularly since the storage is usually completely overwritten."
This isn't always true. However wrote this crap needs to go relearn the concept of a "translation unit" in ANSI/ISO C.
I can't see anything wrong with it. From the standard:
If the lvalue has an incomplete type and does not have array type, the behavior is undefined.
If the lvalue designates an object of automatic storage duration that could have been declared with the register storage class (never had its address taken), and that object is uninitialized (not declared with an initializer and no assignment to it has been performed prior to use), the behavior is undefined.
1 undefined behavior
behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which this International Standard imposes no requirements
2 NOTE Possible undefined behavior ranges from ignoring the situation completely with unpredictable results, to behaving during translation or program execution in a documented manner characteristic of the environment (with or without the issuance of a diagnostic message), to terminating a translation or
execution (with the issuance of a diagnostic message).
3 EXAMPLE
An example of undefined behavior is the behavior on integer overflow.
CUPS for Linux used to have uninitialized variables variables in parts of their program. However, it wasn't undefined behavior because those variables didn't have automatic duration.
>>59
When would you ever shift an integer by a value greater than or equal to its width? The article didn't say pointer aliasing would lead to undefined behaviour. Just that converting a pointer to an incompatible type and then dereferencing it would.
>>60
You're right, but what do translation units have to do with it?
>>65
As mentioned, it's only undefined for automatic variables. The standard says: If an object that has static storage duration is not initialized explicitly, then: — if it has pointer type, it is initialized to a null pointer; — if it has arithmetic type, it is initialized to (positive or unsigned) zero; — if it is an aggregate, every member is initialized (recursively) according to these rules; — if it is a union, the first named member is initialized (recursively) according to these rules.
Name:
Anonymous2012-01-21 15:20
god fucking damn it, i fucked up the quote
Name:
Anonymous2012-01-21 15:28
>>73
Because what this person wrote about only applies to variables that have automatic duration. The blog covers more than that. This is an important distinction because there are some widely used Linux programs that have uninitialized variables. However those variables aren't undefined because they don't have automatic duration.
Name:
Anonymous2012-01-21 15:33
>>73
In some cases, what will happen, is that the variable will no longer be a tentative definition once the translation unit is completed. In other words, the uninitialized variable will in fact, become initialized. And depending on what you're trying to achieve, initializing the varible in such a case may in fact hinder the performance of the program.
Name:
Anonymous2012-01-21 15:37
>>73
Also, I shouldn't have given your stupid ass a response since you apparently have me on some kind of filter. Whatever.
>>76
I don't think the completion of the translation unit is all that relevant. The important thing is that objects with static duration get default values.
Name:
Anonymous2012-01-21 15:42
>>78
An object doesn't have to have static duration in order to get initialized.
>>79
It does according to the standard. Point me to something that says otherwise.
Name:
Anonymous2012-01-21 15:44
>>80
I gave a response under a tripcode, however, you totally ignored it.
Name:
Anonymous2012-01-21 15:45
>>82
I clearly didn't, because I said "as mentioned" and was referring to what you said.
Name:
Anonymous2012-01-21 15:45
>>81
What about global variables? Unless it's changed, it used to be that uninitialized global variables would become zero. In fact, a lot of older Linux code relies on this feature.
Name:
Anonymous2012-01-21 15:47
>>84
A global variable is an object that has static duration.
Name:
Anonymous2012-01-21 15:50
>>85
No. The because "static", when used conjunction with a variable, impacts the duration of the variable. Not its scope.
Name:
Anonymous2012-01-21 15:52
>>85
A variable in C has three properties. Scope, duration, and linkage. Using something like 'static' impacts these three basic properties.
Name:
Anonymous2012-01-21 15:52
>>73
As a veteran assembly programmer, I expect this to work as expected: float foo = xyzzy;
int bar = evil_bit_magic( *(int*)&foo );
foo = *(float*)&bar;
Oh and I expect compilers not to optimize out (x < x+1). If I'm doing the comparison, it's for a reason, I'm not just putting it there for fun. Sure, if you can prove that x will always be smaller than INT_MAX, go ahead and optimize it out, otherwise fuck off. But don't give me undefined behaviour.
Name:
Anonymous2012-01-21 15:55
>>88
I don't think that's undefined behavior because you're not changing the value, but instead, reinterpreting it.
Name:
Anonymous2012-01-21 16:15
>>86
How could something with file scope (i.e. a global variable) not have static duration?
>>88
Strange example. Just cast foo to type int. It's well defined as long as the int can represent the integral part of the float. I don't actually know whether int* to float* and vice-versa is actually undefined. I just know that if they're incompatible in a sense that they're not correctly aligned, the behaviour is undefined. Logic tells me it should be fine (refer to what I first said).
If x is signed, I believe it would be optimized out whether the compiler knows its value or not, because an overflow can occur (undefined behaviour), so either way you're fucked. If it was unsigned, on the other hand, the compiler shouldn't optimize it out.
Name:
Anonymous2012-01-21 16:22
>>90
I was thinking about having a set of uninitialized variables defined in one file, and then having a different C program access these variables. Also, what >>88 isn't that strange because he is reinpreting the value.
Name:
Anonymous2012-01-21 16:24
>>91
And such a move is generally used in your larger programming projects.
>>90 because an overflow can occur (undefined behaviour)
All the architectures I work with use 2's complement for signed integers, so normally I would expect it to be very well defined.
Name:
Anonymous2012-01-21 16:26
>>91
A different C program or a different translation unit? I don't know about a different C program (not sure how that would work out), but objects with static duration are initialized before program startup, so the behaviour would be defined.
I said it was strange because he could just cast the float to int.
Name:
Anonymous2012-01-21 16:28
>>93
As long as you use an implementation that specifies how it deals with integer overflow, you should be fine.
Name:
Anonymous2012-01-21 16:37
>>95
There's a big difference between implementation-defined and undefined behaviour.
Name:
Anonymous2012-01-21 16:39
>>93
Completely irrelevant from the language's point of view. Integer overflow causes undefined behaviour, so anything happening is equally valid.
Name:
Anonymous2012-01-21 16:41
>>95
I don't know. I'm just getting this feeling that there's just too many little things like this, just waiting there to bite me in the allegorical ass. I'm afraid for the security and correctness of my code. Sigh. I don't know, I might actually start working in assembly for my low-level work. But then I'd have to completely rewrite everything for other architectures. That's a lot of extra work. I'm gonna go pop a beer and maybe I'll figure it out eventually.
>>96
I know it would still be undefined behaviour at the end of the day, but in practice, you could get away with it. The best thing to do would be to check whether [code]x[code] is about to overflow.
>>98
Correct me if I'm wrong, but even with assembly you'd still have the same problems. Again, the best thing to do would be to check the value.
>>98
You could spend your time sub-optimally unrolling loops and shuffling registers around like a retard or you could let the compiler do a better job for you.
Name:
Anonymous2012-01-21 17:32
>>101
Slow and secure VS Fast and flawed.
I know what I'd pick.
As a noobish newcomer, I would do this: #include <stdint.h>
union word {
float foo;
int32_t bar;
};
int main() {
union word a = {1.0};
a.bar = evil_bit_magic(a.bar);
}
Why programmers have this hacker syndrome, denying stuff like if (x == INT_MAX) {...}? It's standard and much more readable.
>>104
Writing into one member of a union and reading from another invokes undefined behaviour. I know at least GCC's optimizers take advantage of this fact.
Name:
Anonymous2012-01-21 18:06
>>94 I said it was strange because he could just cast the float to int.
You don't understand that the code isn't changing the value. Instead, it is reinterpreting it.
>>106
No, I couldn't find evidence. Standard only cites that an union is a structure where the storage of all its members overlap. The other way around may produce undefined behavior, if the value assigned to a.bar isn't a valid float. Also, if a.bar overflows, it's better to write: union word {
float foo;
uint32_t bar;
};
Name:
Anonymous2012-01-21 20:14
>>108
ISO/IEC 9899:1999
Annex J J.1 Unspecified behaviour
The following are unspecified:
- The value of a union member other than the last one stored into (6.2.6.1).
§6.2.6.1/7: When a value is stored in a member of an object of union type, the bytes of the object representation that do not correspond to that member but do correspond to other members take unspecified values, but the value of the union object shall not thereby become a trap representation.
Name:
Anonymous2012-01-21 20:58
>>108 >>109
Whelp, ISO/IEC 9899:1999:TC3 seems to have legalized type punning via unions:
§6.5.2.3/3 fn 82: If the member used to access the contents of a union object is not the same as the member last used to store a value in the object, the appropriate part of the object representation of the value is reinterpreted as an object representation in the new type as described in 6.2.6 (a process sometimes called "type punning"). This might be a trap representation.
>>94 A different C program or a different translation unit? I don't know about a different C program (not sure how that would work out), but objects with static duration are initialized before program startup, so the behaviour would be defined.
Informally, in C, variables are named objects. These variables have scope, duration, and linkage. Also, an object is a runtime thing. Ie, it doesn't exist at compile time. Eer....why am I arguing with some faggot that thinks global variables are static?
Why don't you just fucking read the standard and write some code you moron.
Name:
Anonymous2012-01-22 12:21
I declare all my global variables in the data segment because i'm a boss nigger.
check my (postcount % 15) dubs niggas
Name:
Anonymous2012-01-22 12:52
>>114
Are you that same person (kodak_gallery_programmer)? You realize global variables have file scope by definition, right? Since they have file scope, they can't have automatic duration. The object could be a pointer to an object that has allocated duration, but the variable itself would still have static duration.
Name:
Anonymous2012-01-22 13:03
>>116
Again, for the second time, a variable and an object in C aren't the same thing. Which part of this doesn't your monkey ass get?
Name:
Anonymous2012-01-22 13:04
>>116
And again, an object in C is a runtime thing. Now why don't you just shut the fuckup and read the standard instead of giving your own creative interpretation of the language.
Name:
Anonymous2012-01-22 13:25
>>117,118
They refer to the same thing in this context... I don't understand what you're getting at.
Name:
Anonymous2012-01-22 13:29
>>119
No they don't. Why are you trying to argue about something that you clearly don't understand? Anyways, at least in C, it's possible for a variable to not have an associated object with it. Likewise, it's possible to have an unnamed variable.
Name:
Anonymous2012-01-22 13:34
>>120
You mean an uninitialized variable? It would have an indeterminate value, but it would still have been allocated. If by unnamed variable you're referring to unnamed members of a struct or union, again, it would still be allocated somewhere. In the case of a flexible array member, it would have allocated duration.
Name:
Anonymous2012-01-22 13:36
>>119
And more to the point you annoying fucker...
You realize global variables have file scope by definition, right? Since they have file scope, they can't have automatic duration.
I can think of a case where a global variable doesn't have automatic duration. In other words, the variable wouldn't have an object associated with it.
Name:
Anonymous2012-01-22 13:40
>>121 You mean an uninitialized variable? It would have an indeterminate value, but it would still have been allocated.
And what happens if I don't define the variable you annoying shit? Exactly. Now again, I suggest that you actually read a book.
Name:
Anonymous2012-01-22 13:40
>>122
I said they can't have automatic duration. If you don't explicitly initialize a global variable, it's value will be 0, unless of course you only declared the variable, in which case it will just be ignored if you don't provide a definition.
Name:
Anonymous2012-01-22 13:42
>>123
Are you talking about global variables specifically? If you don't define the variable, it is just ignored, as mentioned by my previous post.
Name:
Anonymous2012-01-22 13:44
>>124
unless of course you only declared the variable, in which case it will just be ignored if you don't provide a definition.
Again, that is incorrect you moron.
Name:
Anonymous2012-01-22 13:45
>>125
No, it won't get ignored you idiot. Why don't you just shut the fuck up and write some C code since you clearly don't seem to keen on the whole reading thing.
Name:
Anonymous2012-01-22 13:49
>>126,127
If there's no definition, it can't be allocated. If you try to use that variable, your compiler will spit out an error. Why don't you take your own advice and write some C code?
Name:
Anonymous2012-01-22 13:52
>>128 If there's no definition, it can't be allocated. If you try to use that variable, your compiler will spit out an error.
That's because the compiler isn't ignoring the variable you fucking annoying stupid shit. If the compiler would have in fact ignored the variable, like what you claim, then it wouldn't have spit out an error.
Why don't you take your own advice and write some C code?
I have you annoying stupid shit.
Name:
Anonymous2012-01-22 13:53
>>128
And again, for the third time, you aren't making a clear distinction between the variable and the object. So once again, you're stupid. And once again, you have no possible future as a computer programmer.
Name:
Anonymous2012-01-22 13:58
>>129
It will be ignored. There won't be any trace of it after the program is compiled. However, if you're trying to use it, the compiler will obviously complain. Since you're so fond of the standard: If an identifier declared with external linkage is used in an expression (other than as part of the operand of a sizeof operator whose result is an integer constant), somewhere in the entire program there shall be exactly one external definition for the identifier; otherwise, there shall be no more than one.
Name:
Anonymous2012-01-22 13:59
>>130
Waah waah waah, that's you crying like a baby.
PROTIP: Do not discuss with Kodak. He suffers from schizophrenia and urinary incontinence, which gives him a rather unpleasant attitude. The assiduous presence of such people is the worst thing which can happen to non-moderated boards.
>>131
Also you stupid fucker, in C, a statement, an expression, and an expression-statement are three different thing. Cripes you are one stupid SOB.
Name:
Anonymous2012-01-22 14:05
>>133
Do you care to help the toilet scrubber out?
Name:
Anonymous2012-01-22 14:23
>>134
I can now see why I'm even having to argue with you with something that should be obvious. You can't read. Of course that's not an expression. "Used as an expression" means:
if (foo);
There. I used it as an expression.
Also, int foo; is an external definition, not just a declaration. Just in case you didn't know.
Name:
Anonymous2012-01-22 14:25
>>137
But what you cited related to an expression. Having something like
int foo;
or even
extern int foo;
isn't an expression. So now, let's stay on topic you mental midget.
Name:
Anonymous2012-01-22 14:29
>Also, int foo; is an external definition,
This is an external variable. And again, this variable has scope, duration, and linkage.
Name:
Anonymous2012-01-22 14:44
>>138
No, you misunderstood. It's saying that if the variable is used as an expression, it must be defined. Otherwise, it need not be. However, we're going slightly off-topic. The original argument, that all global variables have static duration, still stands. I don't count variables that have no definition.
>>139
What I'm getting at is that it does have a definition.
The original argument, that all global variables have static duration
This is still incorrect you idiot. Of course the only way you would know this is if you would have written some actual C code instead of arguing with me.
Name:
Anonymous2012-01-22 15:09
>>141
Why don't you point me to somewhere in the standard that says otherwise.
"If the declaration of a file scope identifier for an object or a function contains the storage-class specifier static, the identifiere has internal linkage."
Now you annoying stupid shit, the point is, using static modifies the global variable in such a way that is now has internal linkage. In other words, there passage in no way shape or form implies that global variables have static duration.
Name:
Anonymous2012-01-22 15:17
>>142
The passage says it and my conformant C compiler seems to verify it. The fact that you misunderstood the passage just means that you're a mental midget.
Name:
Anonymous2012-01-22 15:19
>>143
Holy fuck, the storage-class specifier static has nothing to with static duration.
Name:
Anonymous2012-01-22 15:21
>>145
Yes it does. Read the definition of static again you fucking moron.
Name:
Anonymous2012-01-22 15:25
>>146
Better yet, let me cite it for your stupid ass..
Under section 6.2.4
"An object whose identifier is declared with external or internal linkate, or with the storage-class specififer static has static storage duration. Its lifetime is the entire exeuction of the program and its stored value is initialized only once, prior to the program startup."
In other words, 'static storage duration' is a result of using the 'static' keyword you fucking idiot.
Name:
Anonymous2012-01-22 15:25
>>146 An object has a storage duration that determines its lifetime. There are three storage durations: static, automatic, and allocated. An object whose identifier is declared with external or internal linkage, or with the storage-class specifier static has static storage duration. Its lifetime is the entire execution of the program and its stored value is initialized only once, prior to program startup.
I don't know they emphasized that the storage-class specifier static here, but if you use your common sense, a global variable with internal linkage was obviously declared with the static specifier.
>>147
I don't know why they emphasized that, but how about you read that quotation again. If it has external or internal linkage, it has static duration. so it isn't only if you use the static specifier.
Name:
Anonymous2012-01-22 15:29
>>150
Huh? static storage duration is a result of using the static keyword. What part of this doesn't your retarded ass get?
Name:
Anonymous2012-01-22 15:31
>>150
Because the point is fucking stupid shit that properties of the variable change once you remove the 'static' keyword. This is why are emphazing what they are. Holy shit you're stupid.
Name:
Anonymous2012-01-22 15:31
>>151 An object whose identifier is declared with external or internal linkage, or with the storage-class specifier static has static storage duration.
THIS CAN ONLY BE A GLOBAL VARIABLE HURR DURR
Name:
Anonymous2012-01-22 15:34
Actually, if you look at the start of the passage, they clearly state "An object has a storage duration that determines its lifetime"
This is before they talk about 'static'. This implies that a variable, by default, wether it be local or global, doesn't have static storage duration.
Name:
Anonymous2012-01-22 15:36
>>154
No, it implies that static duration isn't the only type of duration in general. However, in the case of global variables, it always has static duration. God damn, just read over what I quoted.
Name:
Anonymous2012-01-22 15:38
>>155
Read the entire passage you fucking idiot. Nowhere does it imply it. And the fact that you think it does just tells me that you are a fucking idiot. Again, the passages doesn't imply it, and again, my compiler seems to verify it.
Name:
Anonymous2012-01-22 15:39
>>155
The 'static' keyword modifies the variable. If there is no 'static', there is no modification. This applies to any variables. Even globals. Again, read it again you fucking moron.
Please tell me you know that static duration and the static specifier are two different things? The latter means that the variable has internal linkage, and is one of the conditions for a variable to have static duration, mutually exclusive. The other is external linkage. Using deduction, it becomes clear that all global variables have static duration, because global variables cannot have no linkage, which is the only other type of linkage.
Now please give your responses a second thought before clicking reply, you inept fuck.
>>158 The latter means that the variable has internal linkage, and is one of the conditions for a variable to have static duration, mutually exclusive.
Yes.
The other is external linkage.
Yes
Using deduction, it becomes clear that all global variables have static duration, because global variables cannot have no linkage, which is the only other type of linkage.
No. Global variables can have linkage you moron.
>Now please give your responses a second thought before clicking reply, you inept fuck.
You're the minimum wage toilet scrubber. Not me.
Name:
Anonymous2012-01-22 15:59
>>159 No. Global variables can have linkage you moron.
I said they cannot have no linkage. The only variables with no linkage are those declared at block scope or function prototype scope. That isn't to say that variables with block scope can't have external linkage (they can if you use the extern storage-class specifier). Check out the standard:
The following identifiers have no linkage: an identifier declared to be anything other than an object or a function; an identifier declared to be a function parameter; a block scope identifier for an object declared without the storage-class specifier extern.
That really isn't clear. You might want to work on your grammar there buddy.
The only variables with no linkage are those declared at block scope
Again, that's incorrect. Those variables have to have some kind of linkage, otherwise, if I compile this C program against another C program, I could access those variables in that block.
Name:
Anonymous2012-01-22 16:08
>>161
The type of linkage just happens to be referred to as "no linkage".
What I quoted is from the standard, and you're saying it's wrong.
Name:
Anonymous2012-01-22 16:11
>>162
Now I see why you don't work any kind of engineering job. You clearly can't comprehend what you read. Again, global variables do not have static storage duration. This fact is pretty clear from reading the standard. Why you keep asserting something that the standard clearly doesn't imply goes beyond me.
Name:
Anonymous2012-01-22 16:13
>>163
Can we agree that global variables have either internal linkage or external linkage?
Name:
Anonymous2012-01-22 16:14
>>164
Yes. However, the rest of it I don't agree with because you are just making unfounded assumptions when reading the standard.
Name:
Anonymous2012-01-22 16:16
>>165
Now read this part: An object whose identifier is declared with external or internal linkage, or with the storage-class specifier static has static storage duration.
No assumptions made at all.
Name:
Anonymous2012-01-22 16:16
>>161
I renig on this response. I was mixing up scope with linkage.
Name:
Anonymous2012-01-22 16:18
>>166
I see an 'or' and not an 'and'. In other words, the latter can be false and the former would still be true.
Name:
Anonymous2012-01-22 16:22
hax anii everyday
anii MUST be haxxed
Name:
Anonymous2012-01-22 16:26
>>168
A variable at block scope with the storage-class specifier static doesn't have internal linkage. That's why it was emphasized, sorry, although it would have been better to say "an object whose identifier is declared with external or with the storage-class specifier static..."
Name:
Anonymous2012-01-22 16:27
"an object whose identifier is declared with external linkage or with the storage-class specifier static..." rather
Name:
Anonymous2012-01-22 16:30
>>170
The topic is about global variables. Not variables at block scope. Now again, try and stay focused you stupid sit.
Name:
Anonymous2012-01-22 16:33
>>172
I'm explaining why it mentions "or with the storage-class specifier static" you moran. I've already said everything I had to say. All that's left is for you to acquire at least a fifth grade reading level.
Name:
Anonymous2012-01-22 16:36
>>173
You're the faggot that is going off topic by talking about unrelated stuff such as variables at block scope. Also,
I've already said everything I had to say. All that's left is for you to acquire at least a fifth grade reading level.
You still haven't explained how having variables at block scope level supports 'global variables have static duration'.
Name:
Anonymous2012-01-22 16:39
>>174
I'm saying if a variable at block scope is declared with specifier static, it has static duration, but not internal linkage. That's why it was mentioned. The fact that variables with external or internal linkage have static duration already supports my claim. I swear if I have to repeat the same thing one more time...
Name:
Anonymous2012-01-22 16:41
>>175
That only applies to variables at block scope. There are other variables. Namely global ones.
Name:
Anonymous2012-01-22 16:42
>>175
And again, you're making the assumption that variables at block scope apply to global variables.
Name:
Anonymous2012-01-22 18:14
C is too complex, error-prone and bloated with undefined behaviour.
Code in assembly instead!
How should I divide my assembly files into modules? Should I use headers with macros and structure definitions (nasm supports both) or should I concatenate everything in one single file? I'll go experiment and see if the linker (GNU ld) is smart enough to DWIM when I use extern and global. by the way I'm coding a toy OS in assembly, no dynamic module loading, monolithic.