Converting c header to delphi

Hi: 
In my c header file I have:
#pragma pack(1)
before a number of c structures.
would using a packed record give the same memory layout or should I use {$align 1}?
Any help apreciated.Cheers
Sean.
0
Sean
2/22/2010 11:31:28 AM
embarcadero.delphi.nativeapi 1236 articles. 1 followers. Follow

5 Replies
679 Views

Similar Articles

[PageSpeed] 2

Sean Farrow wrote:

> Hi: 
> In my c header file I have:
> #pragma pack(1)
> before a number of c structures.
> would using a packed record give the same memory layout or should I
> use {$align 1}? 

Both will do, since a packed record is the same as one aligned on 1. I
would prefer the {$ALIGN 1} approach, though.
-- 
Rudy Velthuis (TeamB)        http://www.teamb.com

"A computer makes it possible to do, in half an hour, tasks which
 were completely unnecessary to do before."
0
Rudy
2/22/2010 1:03:04 PM
Hi: 
if I use {$align 1}, how do I reset hte default alignment?
Cheers
Sean.
> {quote:title=Sean Farrow wrote:}{quote}
> Hi: 
> In my c header file I have:
> #pragma pack(1)
> before a number of c structures.
> would using a packed record give the same memory layout or should I use {$align 1}?
> Any help apreciated.Cheers
> Sean.
0
Sean
2/23/2010 4:29:42 AM
<Sean Farrow> wrote:
> Hi:
> if I use {$align 1}, how do I reset hte default alignment?
> Cheers
> Sean.
>> {quote:title=Sean Farrow wrote:}{quote}
>> Hi:
>> In my c header file I have:
>> #pragma pack(1)
>> before a number of c structures.
>> would using a packed record give the same memory layout or should I 
>> use {$align 1}?
>> Any help apreciated.Cheers
>> Sean.

Sean,

{$ALIGN 1}, {$A1} and {$A-} are synonyms for byte alignment.

Similarily
{$ALIGN 8}, {$A8} and {$A+} are synonyms for quad-word alignment, and 
default, unless you have changed the default setting.

If you don't need to use any other alignment than the default in the 
surrounding code you can just use {$A+} to return to the default 
{$ALIGN 8}

OTOH, if you define the records as 'packed', you dont have to worry 
about the surrounding alignment.

Regards
Tom
0
Tom
2/23/2010 9:10:40 AM
Sean Farrow wrote:

> Hi: 
> In my c header file I have:
> #pragma pack(1)
> before a number of c structures.
> would using a packed record give the same memory layout or should I
> use {$align 1}?  Any help apreciated.Cheers
> Sean.



-- 
Rudy Velthuis (TeamB)        http://www.teamb.com

"To jaw-jaw is always better than to war-war." 
 -- Winston Churchill
0
Rudy
2/23/2010 11:45:03 PM
Sean Farrow wrote:

> Hi: 
> if I use {$align 1}, how do I reset hte default alignment?

{$ALIGN 8} is the only way.

-- 
Rudy Velthuis (TeamB)        http://www.teamb.com

"I wouldn't mind dying - it's the business of having to stay 
 dead that scares the shit out of me." -- R. Geis.
0
Rudy
2/23/2010 11:45:28 PM
Reply:

Similar Artilces:

converting delphi interface files to c++ header files?
Good day all If you would all be so kind and bear with me: i'm rather new in this and i've never worked with Delphi. I have a project in c++ that uses a bunch of dll-s written in delphi. Those dll.s came with a bunch of .INT files, who are aparently pascal(delphi) interface files. Now. Is there a way to convert them to something remotely looking like c++ header files? Thank you very much Best regards > {quote:title=Luka Sostar wrote:}{quote} > Good day all > > If you would all be so kind and bear with me: i'm rather new in this and i've never work...

C/C++ header in delphi project
Hello, I have client dll for comunication with electronic (card with chip) driver license, but manufacturer give me only header for C/C++ and they don't know for Delphi, C#,... So, can I implement .h files into my Delphi projects or is there any solution how to translate this file to pas file for communication with DLL files for those cards. Here is original .h file: // --------------------------------- // #ifndef __eVehicleRegistrationAPI_h__ #define __eVehicleRegistrationAPI_h__ // --------------------------------- #ifndef SD_API #define SD_API extern "C&...

Convert another C++ code convert to delphi
Hello, I need the following code convert to Delphi DWORD files_count; bool error_flag = false; bool bResult; for(DWORD i=0; i < files_count && bResult && !error_flag; i++) { if(std::find(delete_file.begin(), delete_file.end(), i)==delete_file.end()) ........ here delete_file is as std::vector<int> delete_file How to convert this loop and if condition? -- Best Regards Md. Shariful Alam Khan "Md. Shariful Alam Khan" <murad_mouri@yahoo.com> wrote in message news:36441@forums.codegear.com.....

C/C++ header from Delphi DLL project
I am currently writing a DLL in Delphi XE7 (64-bit) to be called from LabView. This is working fine, but it is cumbersome (and thus prone to errors) to create the LabView function, since it all has to be done by hand. If I could automatically create C header files from my Delphi project, there is a wizard in LabView that can read these and do most of the work for you. According to the Delphi documentation you can turn "C/C++ Output file generation" on but it only appears to work for Delphi packages and not for plain DLL's. Am I missing something? If not, is there any other han...

Converting from Delphi 2005 to Delphi XE5
I have developed a number of Windows applications in Delphi 2005. I recently purchased Delphi XE5. I have started by trying to compile an existing 2005 application. I am getting a 7 errors about FMXTeeEditor. [dcc32 Error] E1026 File not found: 'FMXTee.Editor.Brush.fmx' Not able to find a solution to this. Any help greatly appreciated. Did you open every form before compiling? The old forms get updated with new properties when they are opened. I would make a copy of the old project before doing any of this. maybe you have links to the older tchart files....i.e its not usi...

converting delphi code to delphi .NET
Hi,I'm looking at converting quite a bit of old delphi code to delphi .NET .  I'm wondering can it be converted to VB.NET for certain ?  Or perhaps there are some unsupported functions etc in delphi and I should keep the code delphi ?  There are about 10,000 lines of code.   Anyone brave enough to take an estimate on how long it would take to convert 10,000 lines ?is going from delphi to delphi.NET smooth ?   Would going to another language cause complications ?Thanks! mike123   Mike123,   Sorry I can not help, however, I have the s...

Converting C++ to Delphi
Hi All, For some hardware I have to convert C++ header files into Delphi units. I know there's a lot of info at Rudy's Corner, but I am stuck with these two: Any idea how to convert these? #define FG_EVENT_INFO_INIT(x) \ do { \ unsigned int i; \ struct fg_event_info *_x = (x); \ _x->version = 2; \ _x->_pad = 0; \ for (i = 0; i< 64; i++) { \ _x->notify[i] = 0; \ _x->timestamp[i] = 0; \ } \ _x->length = 0; \ for (i = 0; i< 254; i++) { \ _x->data[i] = 0; \ } \ } while (0) struct FieldParamete...

converting C++ to Delphi
Does anyone know where to find some information about converting C/C++ to Delphi. It is a pity that there is not much support for Delphi, almost every example is written in C++. I tried to load the example project into C++ Builder but without success. I know the basics about C++ but I get the shivers if I take a look at some code like --------------------------- #ifdef __cplusplus #ifdef STRICT_DMAMEM_TYPECHECK class dma_mem; #else typedef void dma_mem; #endif class micro; #else struct dma_mem_s; typedef struct dma_mem_s dma_mem; struct micro_s; typedef struct micro...

Converting some delphi to C++
I found a useful ActionMangerHelper component at http://homepages.borland.com/strefethen/info/ABFAQ.htm I'm trying to convert it to c++ but are getting stuck in this function call (Delphi) ActionManager.ActionBars.IterateClients(ActionManager.ActionBars, FindClient); the function FindClient is defined as procedure TActionManagerHelper.FindClient(AClient: TActionClient); begin if Assigned(AClient) and Assigned(FCompareProc) and Assigned(FFoundClient) then exit; // Only find the first occurance FCompareProc(AClient); end; I converted FindClient to this in ...

Convert Delphi 7 to Delphi 2009 [Edit]
Hi! Please, I have a code done in Delphi 7... Now I want to convert Delphi 7 to Delphi 2009 but I'm having problems when compile the code. Error message: +[DCC Fatal Error] Far.dpr(9): F2063 Could not compile used unit 'System.pas'+ Please can somebody help me? Source Download (349KB): http://rapidshare.com/files/256191328/FileManager.rar.html Mirror Source Download: http://www.megaupload.com/?d=12GYLPT0 Password: delphi Thank u so much! (sorry for my bad english, it is not my native language) Edited by: loquax loquax on Jul 15, 2009 12:24 PM Sorry, bu...

Converting Delphi for Win32 to Delphi .Net(Prism)
Hi, I am currently migrating a project from Delphi for Win32 to Delphi.net. Part of my code currently goes into a directory and pulls out a random file from this directory and loads the contents of the file for me. This code doesn't seem to work in Delphi.Net. It uses PString and a number of functions in SysUtils that don't seem to be present in Delphi.net's SysUtils file. If anyone can help me please, it would be greatly appreciated! Many thanks, Jonathan Mackey Jonathan Mackey a écrit : > I am currently migrating a project from Delphi for Win32 to &...

Convert code c# to Delphi
Hi, I need to convert this code to Delphi XE5: {code} int bitsPerPixel = ((int)PixelFormat.Format32bppArgb & 0xff00) >> 8; int bytesPerPixel = (bitsPerPixel + 7) / 8; int stride = 4 * ((props.vidProps.nWidth * bytesPerPixel + 3) / 4); int width = 1920; int height = 1080; Bitmap bmp = new Bitmap(width, height, stride, PixelFormat.Format32bppArgb, (IntPtr)pbVideo); MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageF...

Delphi 2010
*Upgrading from Delphi 2007 to Delphi 2010* (as of February 1, 2010) I bought a new computer in December and decided to upgrade from Delphi 2007 to Delphi 2010. Here are some lessons learned related to the Delphi upgrade, which I hope will make a similar transition easier for others. I still have an insurmountable problem with the speed of the IDE (#13 below). As background, my old system had 3 GB of RAM, 40GB of unused disk, a 3.8 GHz CPU, and ran under Windows XP. My new system has 12 GB of RAM, 770GB of unused disk, a quad core 2.67 GHz CPU, and runs under Win7 Home Edition. ...

Convert C++ code to Delphi
Hello, I need some C++ code convert to Delphi. Below is my code: //declare in header file struct error_found { error_found(AnsiString s, AnsiString vn, AnsiString v, AnsiString urp="") { section=s, value=v, value_name=vn; uninst_reg_path=urp;} AnsiString section; AnsiString value_name; AnsiString value; AnsiString uninst_reg_path; }; std::vector<error_found> reg_errors; typedef std::vector<error_found>::iterator reg_errors_iter; //implement in cpp file if(error_flag) { reg_errors.push_back(error_found(GetRoot...

Web resources about - Converting c header to delphi - embarcadero.delphi.nativeapi

Facebook Begins Converting Users To HTTPS
Are you willing to sacrifice a little bit of speed for a lot more safety? Facebook is asking that very question with its announcement that it ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Vert - simply converting for iPhone, iPad, and iPod touch on the iTunes App Store
Get Vert - simply converting on the App Store. See screenshots and ratings, and read customer reviews.

Converting SIM Card to Micro SIM Card - Flickr - Photo Sharing!
Place new Micro SIM into the iPhone SIM card tray

Ayaan Hirsi Ali on Converting Muslims to Christianity - YouTube
Complete video at: http://fora.tv/2010/07/29/Nomad_From_Islam_to_America_with_Ayaan_Hirsi_Ali Ayaan Hirsi Ali explains her support of missionary ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Converting Churches Into Homes Is The Latest Hollywood Trend
You don't have to be a believer to be moved by the beauty of a church.

Resources last updated: 12/9/2015 10:39:27 AM