Quantcast

Support for __attribute__((packed,aligned(1)))

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Support for __attribute__((packed,aligned(1)))

shreeganesh hegde
Hi,

I want to wrap a C structure using swig. But that structure is defined with __attribute__((packed,aligned(1))) and swig is unable to parse that. So is there a feature/support by which swig can parse it and create a wrapper for that structure.


Thank you.

Regards,
Shreeganesh

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Support for __attribute__((packed,aligned(1)))

Andrew Haining

For the time being you might want to hide it behind a pre-processor directive like so:

 

#ifdef __GNUC__

// GCC struct packing.

#define PACKED __attribute__((__packed__))

#else

// No packing.

#define PACKED

#endif

 

There is a builtin SWIG pre-processor value you could use to guard it, although the __GNUC__ one is more correct and should work fine.

From: shreeganesh hegde [mailto:[hidden email]]
Sent: 02 February 2017 06:22
To: [hidden email]
Subject: [Swig-user] Support for __attribute__((packed,aligned(1)))

 

Hi,

 

I want to wrap a C structure using swig. But that structure is defined with __attribute__((packed,aligned(1))) and swig is unable to parse that. So is there a feature/support by which swig can parse it and create a wrapper for that structure.

 

 

Thank you.

 

Regards,

Shreeganesh


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________



Digital Barriers are world leaders in visually intelligent solutions for the global surveillance, security and safety markets, specialising in zero-latency streaming and analysis of secure video and related intelligence over wireless networks, including cellular, satellite, IP mesh and cloud. www.digitalbarriers.com Digital Barriers e-Mail Confidentiality and Disclaimer This message contains confidential information and is intended only for the individual named. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. Digital Barriers plc is a company registered in England and Wales. Registered number: 7149547. Registered office: Cargo Works, 1-2 Hatfields, London SE1 9PG, United Kingdom. For further information about Digital Barriers, please visit www.digitalbarriers.com.
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Support for __attribute__((packed,aligned(1)))

Andrew Haining

The packing attribute only works on compilers with the __GNUC__ pre-processor builtin. SWIG uses its own pre-processor with its own builtins, which shouldn’t include __GNUC__ (although someone could specify it manually, but shouldn’t). It doesn’t matter to SWIG if the structure is packed or not so it doesn’t cause any harm to swig to omit that information when it’s generating code, then when the __GNUC__ compatible compiler runs over the code it will see the packed attribute. The reason it would be preferable to use __GNUC__ over SWIG is that it will allow compilers to compile the code (albeit, unpacked) without choking on the attribute.

 

From: shreeganesh hegde [mailto:[hidden email]]
Sent: 02 February 2017 10:17
To: Andrew Haining <[hidden email]>
Subject: Re: [Swig-user] Support for __attribute__((packed,aligned(1)))

 

Thank you very much. That helped a lot.

But how exactly the SWIG is able to parse if __GNUC__ is set?

 

On Thu, Feb 2, 2017 at 2:55 PM, Andrew Haining <[hidden email]> wrote:

For the time being you might want to hide it behind a pre-processor directive like so:

 

#ifdef __GNUC__

// GCC struct packing.

#define PACKED __attribute__((__packed__))

#else

// No packing.

#define PACKED

#endif

 

There is a builtin SWIG pre-processor value you could use to guard it, although the __GNUC__ one is more correct and should work fine.

From: shreeganesh hegde [mailto:[hidden email]]
Sent: 02 February 2017 06:22
To: [hidden email]
Subject: [Swig-user] Support for __attribute__((packed,aligned(1)))

 

Hi,

 

I want to wrap a C structure using swig. But that structure is defined with __attribute__((packed,aligned(1))) and swig is unable to parse that. So is there a feature/support by which swig can parse it and create a wrapper for that structure.

 

 

Thank you.

 

Regards,

Shreeganesh


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

 


Digital Barriers are world leaders in visually intelligent solutions for the global surveillance, security and safety markets, specialising in zero-latency streaming and analysis of secure video and related intelligence over wireless networks, including cellular, satellite, IP mesh and cloud. www.digitalbarriers.com Digital Barriers e-Mail Confidentiality and Disclaimer This message contains confidential information and is intended only for the individual named. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. Digital Barriers plc is a company registered in England and Wales. Registered number: 7149547. Registered office: Cargo Works, 1-2 Hatfields, London SE1 9PG, United Kingdom. For further information about Digital Barriers, please visit www.digitalbarriers.com.
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user

 


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________



Digital Barriers are world leaders in visually intelligent solutions for the global surveillance, security and safety markets, specialising in zero-latency streaming and analysis of secure video and related intelligence over wireless networks, including cellular, satellite, IP mesh and cloud. www.digitalbarriers.com Digital Barriers e-Mail Confidentiality and Disclaimer This message contains confidential information and is intended only for the individual named. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. Digital Barriers plc is a company registered in England and Wales. Registered number: 7149547. Registered office: Cargo Works, 1-2 Hatfields, London SE1 9PG, United Kingdom. For further information about Digital Barriers, please visit www.digitalbarriers.com.
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Loading...