473,786 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what does "strict alignment" mean?

The standard says that a char* or void* pointer has the least strict
alignment. But I do not know what is a strict alignment. What does that
mean?
Nov 14 '05
11 8907

"pete" <pf*****@mindsp ring.com> wrote in message
news:41******** **@mindspring.c om...
L. Chen wrote:
Thank you. I have one more question.
Then, if there are two pointers,

int* pn;
double* pd;

is the alignment requirement of pd stricter than that of pn ?


Can't say.

Alignment requirements, go by type.
Alignment requirements are related to size, but two types
of the same size may have different alignment requirements.
While I would expect sizeof double to be larger than
sizeof int usually, it doesn't have to be.

Perhaps more to the point, alignment requirement for double may be stricter
than for long long int. Certain compilers implement moves of double as
(normally slower) long long int moves, in order to avoid misalignment
penalty.
Nov 14 '05 #11
"Tim Rentsch" <tx*@alumnus.ca ltech.edu> wrote

My point was, what C thinks of as a byte is not necessarily the
smallest addressable unit in the machine architecture. Even a machine
that had 8-bit addressable units could have a C implementation where
'bytes' were 16 bits (and that might even make sense if the local
character set were something unicode-like).

"char" is a C word, whilst "byte" is a broader concept. K and R made a
mistake by calling "chars" (a variable holding a character) and "bytes" (the
smallest adressable unit of memory) the same thing. As it happens in English
it makes sense to store characters in eight bits, which is also a common
choice for the size of a byte, but this doesn't hold for other languages and
other architectures.
The fact that an "unsigned char" holds a byte is just something we have to
live with, and the problem is further confounded when C pointers differ from
architecture addresses, whether to support multi-byte chars or to implement
8-bit chars on machines where the underlying byte size is 32 bits. So we can
talk about C bytes and hardware bytes.
Nov 14 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2597
by: ed | last post by:
Folks, I'm attempting to write some OOP with the use strict pragma on an I'm just not getting it to work. Here's an example #!/usr/bin/perl -w use strict; use Automobile; my $file = new Automobile;
14
4097
by: J. Campbell | last post by:
I posted a question some time back about accessing a char array as an array of words. In order not to overrun the char array, I padded it with enough 0x00 bytes to ensure that when accessed as words I wouldn't overrun the array. I was told that this is dangerous and that there could be alignment problems if, for example, I wanted to access the char array elements from non-even multiples of sizeof(int). For example, if I had the array: ...
3
20861
by: signuts | last post by:
I am wondering what it means when a pointer is aligned? Could someone perhaps enlighten me or point me in the right direction? Thank you in advance. -- Sig
5
3914
by: Hendrik Schober | last post by:
Hi, we just run into the problem, that "default" alignment in the project properies dialog seem to be different. We have a project that's a DLL, which is linked with a couple of LIBs. All are with the same solution. All had "Default" set in the "Struct Member Alignment" entry. After some assembler debugging we found out that a struct member that is a member function pointer in
1
6818
by: Andy Crawford | last post by:
Even though I have set Strict Off, it is still on, thus causing this error. Here is the code in a templated Column of a DataGrid: (XPpro, Framework 1.1) <ItemTemplate> <TABLE width="100%"> <TR> <TD class="gridItemStyleNormal" align="left" width="50%"><%# Databinder.Eval(Container.DataItem, "CustomerName") %></TD> <TD class="gridItemStyleNormal" align="left" width="30%"><%# Databinder.Eval(Container.DataItem, "BusinessCategoryDesc")...
3
1359
by: ianakapilotlight | last post by:
We are in the process of moving from .net 1.1 to 2.0 and I dont seem to be able to resolve this problem. In VS2003 the Option Strict was swtiched on in the options menu and this was stored in a project file. In VS2005 there is no project file so this is now stored in the web.config. My web.config shows this :- <compilation debug="true" strict="true" explicit="true">
9
3054
by: Oliver Block | last post by:
Hi, what is the most elegent way to center an image inside a web page. The image is radomly chosen by a cgi script may be 300x400 or 400x300. Are there any alignment commands for images?
0
1251
by: Jean-François Michaud | last post by:
Hello, I was wondering if there was a way around leader-alignment. XSF V3.4 from Antenna House seems to be a very powerful FO -> PDF converter, but it doesn't support this particular attribute from fo:leader. It doesn't support leader-pattern-width either but this can be bypassed by using leader-pattern="use-content" as such: <fo:leader leader-pattern="use-content"> . </fo:leader>
2
1708
by: TomB | last post by:
Take a look at these pages: http://deimos.curious.be/~dusk/test/index.html http://deimos.curious.be/~dusk/test/index2.html They are the exact same code except for the doctype, which isn't included in the index2.html file so it renders in "quirks" mode. However, the way it renders in "quirks" mode is (almost) exactly how I expected the page to render. I want the overflow scrollbar on the
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9492
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.