LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-25-2006, 01:28 AM   #1
rajesh_b
Member
 
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Rep: Reputation: 15
Question #pragma pack directive


hi,
Can any body tell me
#pragma pack directive in visual studio is ISO/ANSI compilant or it is visual studio specific one. If i use this directive the code will be portable or not?


Regards,
Rajesh
 
Old 09-25-2006, 01:56 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
I don't know which version of Visual Studio you're using ... but the one I'm familiar with (MSVC++ 5/6) is absolutely not portable.

Most compilers have some equivalent for byte alignment; sometimes pragma's (like MSVC), sometimes compiler options. Here's an example:
Code:
#if defined(WATCOM)
  _Packed
#elif defined(WIN32)
  #pragma pack(push, 1)
#endif
struct o_backup_bowler_rec 
{
  char name[21+1];
  char init[3+1];
  WORD bowler_num;
  BYTE keeping;
#if defined(LINUX)
} __attribute__ ((packed));
#elif defined(WIN32)
};
#pragma pack (pop)
#else
};
#endif

Last edited by paulsm4; 09-25-2006 at 02:04 AM.
 
Old 09-25-2006, 05:05 AM   #3
rajesh_b
Member
 
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Original Poster
Rep: Reputation: 15
hi

thanks for the reply.
Then i need to see the compiler manual to see what needs to be done for packing.

Regards,
Rajesh
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable warnings with a pragma (g++) Kikazaru Programming 3 07-01-2006 10:58 PM
Linux equivalents for #pragma DavidW567 Programming 2 03-09-2005 02:24 PM
apache User directive merchtemeagle Linux - Software 2 03-07-2005 04:42 PM
Apache Directive sopiaz57 Linux - Security 2 12-09-2003 02:32 PM
Pragma: no-cache workaround OhLordy Linux - Networking 1 05-09-2003 06:18 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration