C++Builder TFileStream compatibility between debug and release app versions - c++builder

Using TFileStream to write various values and Strings to a file I found that I can't share file between the debug and release versions of my application.
Looking further it seems that enum types are not write/read the same length using TFileStream.
Example :
If I write to the stream something like using the debug version :
fsStream->Write((void*)&FInstrumentStatus, sizeof(TInstrumentStatus));
it can't be read from the release version, and opposite is the same.
Other values like Strings, int, double, float seems fine.
Since I do have many files created from the debug version, what can I do to get the release version read/write the same?
Thank you,
rwil

Related

Obtain the HDF5 file format version of a file

Given a certain HDF5 file (HDF5 format), how can I know the version of the file format that has been used for its creation?
Context. It is said in the documentation that when you create/write a file the library the following applies for backward compatibility:
An HDF5 Library of any given release is designed to read all existing
HDF5 files from that or any prior release. Although major versions
sometimes contain features that require additions and/or changes to
the HDF5 file format, the library will by default write out files that
conform to a maximum compatibility principle. That is, files are
written with the earliest version of the file format that describes
the information, rather than always using the latest version possible.
This provides the best forward compatibility by allowing the maximum
number of older versions of the library to read new files.
I have tried tools like h5stat but it does not output the info that I want.
Thank you.
Here is an answer in the last question https://ftp.hdfgroup.org/hdf5-quest.html#h5dumpvers
Q: Can you add an option to h5dump or h5ls to print the version of a file ?
A: No, we do not plan on adding this option. Users should use attributes to specify the version of a file. There are many reasons why we shouldn't add this. For example, different objects in the file could be created or modified by different versions of the library.

How to match map/dbg symbols file to delphi-written process

I have a map file created by delphi compiler and I need to use it to analyze DMP file.
I converted the map file to dbg file, using Map2dbg.
The problem is that the process has a different signeture then the symbols.
I tried to use chkmatch to match the signeture, but I'm getting:
Error: Debug information not found in the executable
I guess this is because it is a delphi process.
Does anyone know how to match the signatures?
I made a minidumpreader some time ago:
https://asmprofiler.googlecode.com/svn/trunk/MiniDumpReader/ViewMinidump.exe (old link)
https://github.com/andremussche/asmprofiler/tree/master/Releases/ViewMinidump.exe (new link)
It is written in Delphi with jclDebug.pas so it supports all delphi debug symbols.
And because of this it has line number support (which map2dbg or tds2pdb don't have).
Note: I haven't made map2dbg or tds2pdb myself, just hosting it so other can easily find it

OS X: convert .dylib to .a/.o (dynamic to static)?

Suppose I've read this caveat, and I still want to use TBB as a statically-linked library. (Pretend I'm working in an environment where users aren't allowed to create their own dylibs.) But I don't really want to rewrite the TBB makefile to generate libtbb.a instead of libtbb.dylib.
Is there a simple command-line way to convert libtbb.dylib into libtbb.o with the same entry points?
I have heard a good argument for not being able to go the other way, from static to dynamic. Namely: dynamic libraries need to be PIC, and converting a non-PIC static library to PIC isn't feasible. But that argument doesn't apply in the other direction, as far as I know.
Here's someone saying it's impossible to convert .dll to .a on Windows, but I think they're just talking about the impossibility of breaking a .dll or .exe back up into its original .o files, not necessarily saying it would be impossible to create a linkable .o file with the same contents. Also, the situation on Windows is slightly odder than "real" PIC, although I don't think that's relevant.
Intel Threading Building Blocks (TBB) is available as binary for Windows, Mac and Linux. If you expect to use libtbb.dylib from the Mac distribution on iOS then you are out of luck. The Mac distribution is targeted for Intel (32 and 64 bits). Since iOS runs on ARM processors, you could not use it, even if you found a way to convert a dynamic library to a static library.
If you found a libtbb.dylib file somewhere else targeted for ARM, then you could probably use it on iOS. It's actually possible to load dynamic libraries on iOS. Have a look at the dlopen(3) man page.
Finally, you should read about Grand Central Dispatch (GCD) instead, which is built-in support for concurrent code execution on multicore hardware in iOS and OS X.

Apple's caution in its documentation of + (NSMethodSignature *)signatureWithObjCTypes:(const char *)types

In Apple's documentation of this method, it says the following at the end:
Special Considerations
This method, available since Mac OS X v10.0, is exposed in Mac OS X v10.5. Only type encoding strings of the style of the runtime that the application is running against are supported. In exposing this method there is no commitment to binary compatibily supporting any "old-style" type encoding strings after such changes occur.
It is your responsibility to pass in type strings which are either from the current runtime data or match the style of type string in use by the runtime that the application is running on.
I'm afraid I didn't understand that. Can anyone explain?
What I really want to know is this: If I write an iOS app that uses this method, are they saying it might break on me at some later time, if Apple changes the way it does something?
I am using Cocoa . . .
What I really want to know is this: If I write an iOS app that uses this method, are they saying it might break on me at some later time, if Apple changes the way it does something?
Yes. They are saying that they might change the format of the type encoding strings (the argument of the method) in future versions.

Bluetooth on Lazarus/FreePascal on Mac OS X

Has anyone used Bluetooth on Mac OS X with Lazarus or FreePascal? There is a bluetooth unit, but it currently only supports Linux.
Information about existing unit:
http://wiki.freepascal.org/Bluetooth
I plan to enhance this to support Mac OS, but it would be nice to know if anyone has written any code to use BlueTooth on Mac OS already to avoid duplicated work.
On the other hand, if you have used XCode to access Bluetooth, what libraries did you use? I am sure I can discover this with the XCode profiler by opening some Bluetooth applications.
Note: Mac OS X doesn't appear to use the BlueZ library that Linux has, so I don't think the solution is as easy as changing the library path. Instead, it has IOBluetooth "Framework", located at /System/Library/Frameworks/IOBluetooth.framework.
Having a look, it looks like:
kaikei.ocn.ntt.com:IOBluetooth.framework $ file *
CodeResources: XML document text
Headers: directory
IOBluetooth: Mach-O universal binary with 3 architectures
IOBluetooth (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
IOBluetooth (for architecture i386): Mach-O dynamically linked shared library i386
IOBluetooth (for architecture ppc7400): Mach-O dynamically linked shared library ppc
Resources: directory
Versions: directory
On the other hand, I think if anyone had done this already, I would probably be able to find it on Google.... On the off chance I am wrong, please reply and let me know.
Clarification: I have created bindings for normal shared libraries before (f.e. sqlite3), but not for a "framework". If nobody has created bindings or otherwise used the MacOS Bluetooth framework from FreePascal, advice on how to use framework functions from FreePascal in general woule be appreciated. (And normally the functions I am porting are C based, not Obj-C, so I am not sure how to declare Obj-C methods in FPK, although I am sure I will be able to find some samples if I keep searching).
The main svn repository for translated Mac OS X framework C headers is http://svn.freepascal.org/svn/macosxintf/trunk
From time to time, FPC releases are synchronised with the latest versions hosted there. Note that the files in that repository (in the MPPInterfaces subdirectory) are in a generic format that can be automatically translated into either FPC, GPC or CodeWarrior Pascal versions.
To generate the FPC versions, use "make fpcpinterfaces", and find the results in the Build/FPCPinterfaces folder.
To translate new headers, execute something like this from inside a checked out copy of the macosxintf repository:
./Scripts/Convert.pl /System/Library/Frameworks/IOBluetooth.framework/Headers/IOBluetooth.h FORCE MPPInterfaces
Afterwards, you'll still have to edit the resulting file to add/remove units and clean up some other things not handled by the automatic translation process. Once finished, you may want to submit a bug report at bugs.freepascal.org with the finished units.
(note: because I'm unregistered, I can only add in one url per post, so the next url's are a bit mangled to get around that restriction)
You can also subscribe to the Mac Pascal list (lists.sonic.net/mailman/listinfo/mac-pascal) and ask there whether someone already translated those headers.
The Bluetooth framework indeed also contains some Objective-C headers. Objective-Pascal support is only available in the latest FPC svn versions, as described on the FPC wiki (google FPC_PasCocoa). You need this support in order to interface with Objective-C.
Translating Objective-C is probably easiest using the script elsewhere in FPC's svn (svn.freepascal.org/svn/fpc/trunk/packages/cocoaint/utils/)
You may want to ask for help on the above-mentioned Mac Pascal list, as all people maintaining the aforementioned translations and translation tools are subscribed there.

Resources