473,652 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

porting issues ?

Hi,
Can somone please describe the problems one would face when we try
to port a software written in C to another platform some of them being
endianness ,alignment,data types etc ?

It would be very helpful if you could state the solution along with
problem .Also can you please give me some pointers and links to
documents so that porting can be easily accomplished ?

Navin
-
Nov 13 '05 #1
19 3462

"navin_2016 " <na********@yah oo.co.in> schrieb im Newsbeitrag
news:26******** *************** ***@posting.goo gle.com...
Hi,
Can somone please describe the problems one would face when we try
to port a software written in C to another platform some of them being
endianness ,alignment,data types etc ?
There should be no problem as long as you strictly adhere to the C standard
(which is seldom possible).
If you put nonstandard stuff into separate compilation units, porting will
at least be easier than if you mix standard and nonstandard things
everywhere.
It would be very helpful if you could state the solution along with
problem .Also can you please give me some pointers and links to
documents so that porting can be easily accomplished ?

Navin
-

Nov 13 '05 #2
navin_2016 wrote:

Can somone please describe the problems one would face when we
try to port a software written in C to another platform some of
them being endianness ,alignment,data types etc ?


If you adhere to the C standard, you should have no problems with
any of those, barring the use of binary files created or used by
other systems. That you can avoid by using text.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Nov 13 '05 #3
CBFalconer wrote:

If you adhere to the C standard, you should have no problems with
any of those, barring the use of binary files created or used by
other systems. That you can avoid by using text.


Could you explain what specific problems you are referring to with
respect to binary files?

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Nov 13 '05 #4
nrk
Kevin Goodsell wrote:
CBFalconer wrote:

If you adhere to the C standard, you should have no problems with
any of those, barring the use of binary files created or used by
other systems. That you can avoid by using text.


Could you explain what specific problems you are referring to with
respect to binary files?

-Kevin


One problem that comes to mind is reading/writing using fread/fwrite
(structs, ints, floats etc.)...

-nrk.
Nov 13 '05 #5
Kevin Goodsell wrote:

CBFalconer wrote:

If you adhere to the C standard, you should have no problems with
any of those, barring the use of binary files created or used by
other systems. That you can avoid by using text.


Could you explain what specific problems you are referring to with
respect to binary files?


For starters, see Question 20.5 in the comp.lang.c
Frequently Asked Questions (FAQ) list

http://www.eskimo.com/~scs/C-faq/top.html

.... and don't forget to follow the links you'll find there.

--
Er*********@sun .com
Nov 13 '05 #6
nrk wrote:
Kevin Goodsell wrote:

CBFalconer wrote:

If you adhere to the C standard, you should have no problems with
any of those, barring the use of binary files created or used by
other systems. That you can avoid by using text.


Could you explain what specific problems you are referring to with
respect to binary files?

-Kevin

One problem that comes to mind is reading/writing using fread/fwrite
(structs, ints, floats etc.)...


Yes, but neither Chuck nor I would do that.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Nov 13 '05 #7
Kevin Goodsell wrote:
CBFalconer wrote:
If you adhere to the C standard, you should have no problems with
any of those, barring the use of binary files created or used by
other systems. That you can avoid by using text.


Could you explain what specific problems you are referring to with
respect to binary files?


For example, endianness, sizeof various entities, value of
CHAR_BIT, etc.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Nov 13 '05 #8
CBFalconer wrote:
Kevin Goodsell wrote:

Could you explain what specific problems you are referring to with
respect to binary files?

For example, endianness, sizeof various entities, value of
CHAR_BIT, etc.


The only one of those that seems like a serious problem to me is
CHAR_BIT. Byte-order and the number of bytes for a given field would be
determined by the file format, which must be agreed upon by both sides
regardless of whether it's text or binary.

But, if the source and destination machine use different byte-sizes, I'm
not sure what you'd do, partly because I don't know how the file would
be translated. Obviously a file with 9-bit bytes moved to a machine with
8-bit bytes needs to be converted somehow. Suppose the conversion
consists of throwing away the high-order bit for each byte. In that
case, you just make sure you don't use that bit - limit yourself to the
8-bit range for each byte.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Nov 14 '05 #9
On Mon, 08 Dec 2003 23:19:16 GMT, CBFalconer <cb********@yah oo.com>
wrote in comp.lang.c:
Kevin Goodsell wrote:
CBFalconer wrote:
If you adhere to the C standard, you should have no problems with
any of those, barring the use of binary files created or used by
other systems. That you can avoid by using text.


Could you explain what specific problems you are referring to with
respect to binary files?


For example, endianness, sizeof various entities, value of
CHAR_BIT, etc.


I'm curious, Chuck, because I know you're a long time embedded systems
programmer with experience on many different architectures, as I am.

Have you ever worked on a platform where CHAR_BIT was NOT 8? I've
done some Analog Devices SHARC work where CHAR_BIT was 32, and I'm
doing a lot of work on a TI 2812 DSP right now where CHAR_BIT is 16.

If you have worked on platforms where CHAR_BIT was greater than 8,
have they always had signed and unsigned char having the same
representation as signed and unsigned int (if not also signed and
unsigned long)?

Note that many standard functions, particularly all FILE * streams,
are impossible to implement on a platform where UCHAR_MAX == UINT_MAX,
since all file input if built on fgetc(), which can return any
unsigned character value from 0 to UCHAR_MAX, and EOF which must be a
negative integer and have a recognizably different bit pattern from
the above.

As for dealing with data internally on platforms with CHAR_BIT > 8,
it's not really all that hard. All the code in my chapter of C
Unleashed is "CHAR_BIT > 8" safe, because you only use the 8 least
significant bits an unsigned char and ignore anything else.

In the real world, I recently wrote both ends of a parser/formatter
for a proprietary CAN bus protocol. CAN messages (as you probably
know, but others might not) contain between 0 and 64 bits of data,
packed into 0 to 8 octets of 8 bits each.

My parser and formatter can pack and unpack various 8, 16, and 32 bit
values from any possible starting point in the data field of such a
packet into a signed or unsigned 8, 16, or 32 bit data object.

Since the processor on one side of the protocol was a TI DSP with
CHAR_BIT 16, it was written with "CHAR_BIT > 8" portability in mind.
The resultant source code compiles and runs properly both on the DSP
and on the other end of the CAN bus, where the ARM processor does have
8 bit character types.

There is only one tiny bit of surplus code to achieve that
portability. At one point there is an expression where an unsigned
char value is updated like this:

uc = (uc << 2) & 0xff;

....the mask is unnecessary when CHAR_BIT is 8 but is necessary on the
DSP because other parts of the code require all bits above 8 in the
unsigned char (if any) always be 0.

The value of CHAR_BIT is not much of a deterrent to portable code if
you give it a little thought and avoid using more than 8 of them even
when they are available.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3364
by: eichin | last post by:
One of my recent projects has involved taking an accretion of sh and perl scripts and "doing them right" - making them modular, improving the error reporting, making it easier to add even more features to them. "Of course," I'm redoing them in python - much of the cut&paste reuse has become common functions, which then get made more robust and have a common style and are callable from other (python) tools directly, instead of having to...
2
1898
by: Anand | last post by:
Hi Are there any tools that would help in porting code from Pyton 2.3 to 2.4 ? I have gone through the whatsnew documents and created a document comparing Python 2.4 to 2.3. But so far has not been able to find any tool that will signal code in Python 2.3 that can cause errors in Python 2.4 . rgds
7
2147
by: Sonny | last post by:
I need to port a library that is written entirely in C to C++. The library is supported on quite a few platforms (windows, Solaris, Linux, AIX, HP-UX, OSX, etc...) and there's quite an existing customer base that uses it. I need to maintain backwards compatibility such that existing users won't have to do anything to their existing applications other than a re-compile when they upgrade to this new version of the library. I figure that I...
4
2003
by: golu | last post by:
Has any body done the porting from oracle to sql server, what were the issues in porting the data bases? Also suggest some resources which can be helpful in the porting project TIA Golu
0
1204
by: Raymond L. Buvel | last post by:
I am preparing to release an extension module that interfaces Python to the Class Library for Numbers (http://www.ginac.de/CLN/). This module will provide Python types for arbitrary precision floating point numbers, rational numbers, and their complex counterparts. The module also includes most of the functions found in the Python math and cmath libraries. This module will be useful in applications where gmpy...
16
2125
by: Mohanasundaram | last post by:
Hi All, We are working on porting a product written in C and C++ from 32 bit to 64 bit. We need to maintain both 32 bit and 64 bit versions in the future. We took the 32 bit source code and copiled it using a 64 bit compiler and fixed all the compilation warnings. Compilation went through fine but the product breaks in lots of places. We understood that porting a 32 bit code to 64 bit platform is not just a matter of compilation. We...
1
1732
by: Massimo Mannelli | last post by:
I know it is a 10 years old question, but I need to know if there are some issues, procedures, websites, people that have already done the porting from a borland 4.0 to the Microsoft Visual enviroment. I do not care about GUI problems. I want only to focus on 1)the serial communication 2)the .h files need to be converted in another type? 3)in Borland 4.0 the whole project was a .ide file, how could I
5
3266
by: BK-Chicago | last post by:
I am in the midst of porting a massive MFC application from VS6.0 to VS8.0. While i have fixed most of the compile time errors, i do have quite a linker error that i have not been able to resolve. The error i get is Error 100 error LNK2001: unresolved external symbol "public: virtual void __thiscall CWnd::PostNcDestroy(void)" (?PostNcDestroy@CWnd@@UAEXXZ) Evenout.obj I have about 200 of these on almost all the obj's that have a dialog...
5
3024
by: shobhah | last post by:
Hi, We have a complete succsssfully working product on 32bit sparc solaris machine for which compiler used is CC 5.8 Now we are migarting our product from 32 bit to 64bit sparc solaris machine. While porting we need 64 bit compiler issues for our application product which is wriiten in completely C++. We tried with -xarch=v9 and -xport64=full compiler options to find out 64bit porting problems. But we did not find any issues for our...
0
8279
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8589
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.