468,497 Members | 1,877 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,497 developers. It's quick & easy.

__unaligned before and after the * (64bit)

Udi
Hi All,
I'm not sure I understand the difference between placing the
__unaligned before or after the *:
I was trying to handle the C4366 warning - "The result of the unary
'&' operator may be unaligned") and used the '__unaligned' modifier as
suggested,
but ended up with C4090 - "different '__unaligned' qualifiers". (See
below)
However, moving the __unaligned keyword after the ' * '
solved the warning but I'm not sure I solved the probelm.
with no __unaligned keyword --Warning C4366
`````````````````````````````````````````````````` `````````````````````
void List_Clear(List *pList) ;
:
List * pSubscribersList = NULL;

pSubscribersList = (List *)&(p->subscribersList); //C4366: The result
of the unary '&' operator may be unaligned
List_Clear(pSubscribersList);


__unaligned before the * --warning C4090
`````````````````````````````````````````````````` `````````````
void List_Clear(List *pList) ;
:
List __unaligned * pSubscribersList = NULL;

pSubscribersList = (List __unaligned *)&(p->subscribersList);
List_Clear(pSubscribersList); //warning C4090: 'function' : different
'__unaligned' qualifiers
__unaligned after the * --no warnings
`````````````````````````````````````````````````` ``````
void List_Clear(List *pList) ;
:
List * __unaligned pSubscribersList = NULL;

pSubscribersList = (List * __unaligned)&(p->subscribersList);
List_Clear(pSubscribersList); // OK - no warning

Can anyone explain what's the difference between the last two
examples?
I'm using VS2005 compiling to 64 bit.
Thanks!
Mar 19 '08 #1
3 5910
On 19 Mar, 08:53, Udi <UdiBenSen...@gmail.comwrote:
I'm not sure I understand the difference between placing the
__unaligned before or after the *:
<snip>
I'm using VS2005 compiling to 64 bit.
__unaligned isn't part of standard C. You needd to ask ona compler
specific news group. Try I Microsoft related ng.
--
Nick Keighley
Mar 19 '08 #2
Nick Keighley <ni******************@hotmail.comwrites:
On 19 Mar, 08:53, Udi <UdiBenSen...@gmail.comwrote:
>I'm not sure I understand the difference between placing the
__unaligned before or after the *:

<snip>
>I'm using VS2005 compiling to 64 bit.

__unaligned isn't part of standard C. You needd to ask ona compler
specific news group. Try I Microsoft related ng.
Better yet, re-write the code to avoid the need to use __unaligned.
The original poster appears to be writing code for a linked list.
There's no need to use any implementation-specific extensions for such
a relatively straightforward task.

Apparently the compiler's warning "The result of the unary '&'
operator may be unaligned" included a suggestion to use __unaligned.
I strongly suspect that suggestion was a poor one.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Mar 19 '08 #3
Udi wrote:
I'm not sure I understand the difference between placing the
__unaligned before or after the *:
I guess, it works like 'const', which applies to the left unless it is at
the leftmost side, then it applies to the right. However, it is, as others
pointed out, non-standard, so you have to consult the compiler docs.
I was trying to handle the C4366 warning - "The result of the unary
'&' operator may be unaligned") and used the '__unaligned' modifier as
suggested, but ended up with C4090 - "different '__unaligned' qualifiers".
(See below)
However, moving the __unaligned keyword after the ' * '
solved the warning but I'm not sure I solved the probelm.
I don't think so...
>
void List_Clear(List *pList) ;
:
List * pSubscribersList = NULL;

pSubscribersList = (List *)&(p->subscribersList); //C4366: The result
of the unary '&' operator may be unaligned
Well, the first problem here is that you are using casts, which is typically
a sign that something's wrong. Remove those, and you won't need any
unaligned attributes. If it doesn't compile then, your types simply don't
match, but adding them doesn't change that. If you can't do it yourself or
want to verify the solution is correct, please boil your problem down to a
minimal but complete example, in particular guessing
what 'p->subscribersList' could be is pretty hart.

Uli

Mar 19 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Christian McArdle | last post: by
1 post views Thread by GaryDean | last post: by
2 posts views Thread by M O J O | last post: by
4 posts views Thread by Zorro | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.