Content deleted Content added
Tag: |
|||
(16 intermediate revisions by 10 users not shown) | |||
Line 1:
{{lowercase title}}
{{Talkheader}}
{{WikiProject
{{WikiProject C/C++|importance=High}}
}}
== Article or redirect? ==
Line 20 ⟶ 23:
:"''For example, common Internet protocols rely on the fact that C compilers insert padding between struct fields in predictable ways [...]''"
Is this an example of [[type punning]]? --[[User:Abdull|Abdull]] ([[User talk:Abdull|talk]]) 22:52, 2 January 2010 (UTC)
:I don't think so. I think it was ''intended'' for uses such as those shown in the example, and not, as ''Type punning'' characterized it{{mdash}}a ''subversion''. See [[#Stuctural padding]] below. — [[User:Cpiral|<
== Call by reference or call by value? ==
Line 32 ⟶ 35:
*The internal alignment of data members is not unique to the C struct. There is an analogous dynamic that also "works as expected" concerning subclassing in C++. That said it is very interesting that even if a C compiler is run "unaligned" it will always align (don't say "pad"?) struct members ''inside'' the struct, guaranteeing this manipulation by a sub-struct of quantity N-last elements manipulating its containing struct of N elements.
Salient internals for our lead section are the '''size''' (as mentioned), and the method of '''chaining''' the members of a C struct to one another.
— [[User:Cpiral|<
== Declare/define ==
Line 51 ⟶ 54:
::As a Java and Python programmer who has never worked with C, I find this article difficult to understand. I think the biggest reason is that the explanation is almost entirely in code (which is difficult to understand if you aren't familiar with C syntax), and it lacks a high level description of what a struct is for and more importantly ''why'' anybody would want to use one. I think it would also be helpful to draw parallels between it and similar concepts in other languages. I get the impression that this is maybe like Java's Enum type, but the article doesn't say what languages use structs, aside from C, and what equivalencies, if any, exist in other languages. -[[User:Thunderforge|Thunderforge]] ([[User talk:Thunderforge|talk]]) 20:05, 14 October 2013 (UTC)
::That doesn't really matter does it? Wikipedia is for a general audience. If an article is not useful in such a context, it doesn't belong here. If it is useful, it should at least be a stated goal to ''make'' it understandable by a general audience, even if it currently isn't. <small class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/82.9.176.129|82.9.176.129]] ([[User talk:82.9.176.129|talk]]) 23:31, 7 November 2014 (UTC)</small><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
==Not too==
Yes, the article is atypical and maybe too much intended for someone with experience in programming BUT it is not an article about a beginner topic! this article has immense value for one who wants to lookup special attributes of the "struct" in the C programming language. I think the advice or request for rewrite should say something else: "The article needs a longer introduction of dictionary character, which in turn should direct the reader to the general article on //records//."
--[[User:Donald j axel|d-axel]] ([[User talk:Donald j axel|talk]]) 23:07, 20 June 2016 (UTC)
== Incorrect statement ==
Line 67 ⟶ 73:
In the examples, this uses the variable "point" but also talks about pointers. It can get confusing to know which one is being referred. Perhaps changing the arbitrary name of the variable to some like "___location" might make the example clearer. <small class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/199.116.175.88|199.116.175.88]] ([[User talk:199.116.175.88|talk]]) 12:53, 7 May 2015 (UTC)</small><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
Also, there is a line of code in the article {ie. typedef struct point point; } that has two words 'point point'. This is sort of like the life story of many documents --- introducing confusing things without explaining it. To the newcomer of the language, they will probably have no idea what that means. It is also off-putting for newcomers when confusing details or code like that is just placed there, without some kind of explanation - such as this style follows some kind of convention. [[User:KorgBoy|KorgBoy]] ([[User talk:KorgBoy|talk]]) 23:33, 3 June 2018 (UTC)
== What directly corresponds data type the Assembly Language has? ==
Line 74 ⟶ 83:
I think there should be some clarification.
[[Special:Contributions/188.120.152.177|188.120.152.177]] ([[User talk:188.120.152.177|talk]]) 14:11, 27 November 2015 (UTC)
:Yes, the statement needs clarifying. The author might have had in mind the nomenclature of a particular assembly language or a macro name; but, otherwise, the statement appears erroneous. Struct is definitely the sort of complex data structure that complilers, not assemblers, deal with. So, there shouldn't be a one-to-one correspondence. [[User:Dhtwiki|Dhtwiki]] ([[User talk:Dhtwiki|talk]]) 22:44, 27 November 2015 (UTC)
::Various assemblers supported, and presumably still support, structs; Google 'asm struct' for confirmation. I suspect that C was first and assemblers added support to make it easier to call assembly modules from C. I think the assembler would be told to assume that some index register was pointing to a block of memory holding a struct, and the program could then use symbols (labels) as offsets within the struct. However, that is esoteric history and not much use to explain what a struct is. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:45, 27 November 2015 (UTC)
|