__declspec(align(16)) and function parameters

This is a discussion on __declspec(align(16)) and function parameters within the C++ Programming forums, part of the General Programming Boards category; Hello, I am using align(16) to align a structure. I use typedef __declspec(align(16)) Vector3 Vec3; Now, I am passing that ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    132

    __declspec(align(16)) and function parameters

    Hello,
    I am using align(16) to align a structure. I use
    typedef __declspec(align(16)) Vector3 Vec3;

    Now, I am passing that Vec3 to a function, but the compiler (MSVC++ 7) says that Translate': formal parameter with __declspec(align('16')) won't be aligned

    Can't align(16) structures be used as parameters?
    Y3K Network http://www.y3knetwork.com
    Bringing the software of the future on the net.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    Why would you want to pass a (large?) structure by value anyway?

    Why not pass a pointer (or a reference) to the structure, then it will maintain its alignment since it's not actually copied anywhere.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,607
    That use of align() will only align the Vec3 instance of Vector3.

    Read more about it here.

    gg

  4. #4
    Registered User
    Join Date
    Jun 2002
    Posts
    132
    So what should I do to pass a structure which has the align(16) in front of it?
    Y3K Network http://www.y3knetwork.com
    Bringing the software of the future on the net.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. function with variable number of parameters
    By mikahell in forum C++ Programming
    Replies: 3
    Last Post: 07-23-2006, 03:35 PM
  3. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 07:55 AM
  4. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  5. Replies: 5
    Last Post: 02-08-2003, 06:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21