Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:02:44+00:00 2026-06-02T15:02:44+00:00

I want my c++ program compiled under GCC to have maximum alignment of 4

  • 0

I want my c++ program compiled under GCC to have maximum alignment of 4 bytes (of members of structures). I really can do this through #pragma pack directive. However, it’s uncomfortable in my case because the project is quite big, and I would need to make a single header with #pragma pack, that has to be included everywhere. Now, the gcc compiler has an option -mstructure-size-boundary=n documented here http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#ARM-Options , it says “Permissible values are 8, 32 and 64.” In practice, when I try to set it to 4 bytes compiler throws a warning “structure size boundary can only be set to 8, 32 or 64” (surprising, eh?). But why I CAN set it to 4 through #pragma? Does anybody know how to set gcc struct alignment to other values than 8-32-64 through compiler settings?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:02:44+00:00Added an answer on June 2, 2026 at 3:02 pm

    You understood the mstructure-size-option wrong. It refers to the size of the structure (as the name indicates). This does NOT relate to the alignment of the members. For that you could use (besides the pragma) the option -fpack-struct[=n].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I execute a c program under another one. Assume you have one
I have to use a header file after the program is compiled. This header
I want to compile a simple C program with GCC. What do I need
I want to program something in both C# and F#. I have partial classes
I want to compile a very basic hello world level Cuda program under Linux.
If I want to compile a program that is written in Ada, I have
i want to use the Java program in JSP. i have created java program
Suppose I have several 200mb+ files that I want to grep through. How would
I have boost installed under /home/username/local/include . I want to compile a library with
I have a program. I want it to be able to mmap a particular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.