Like Tree1Likes
  • 1 Post By christop

Run code from different arch

This is a discussion on Run code from different arch within the C Programming forums, part of the General Programming Boards category; I've developed a small (very small) ftp client and server. Both of these programs compile and run well only if ...

  1. #1
    Registered User
    Join Date
    May 2012
    Location
    Italy
    Posts
    52

    Run code from different arch

    I've developed a small (very small) ftp client and server.
    Both of these programs compile and run well only if they use the same arch.


    1. If client is Ubuntu amd64 and server is Ubuntu i386 i got a segfault (i think it is a pointer problem)
    2. If client is Ubuntu amd64 and server is Ubuntu amd64 all ok
    3. If client is Ubuntu i386 and server is Ubuntu i386 all ok

    How can i made these 2 programs working on different archs?
    It is a code problem? If so what i have to do?
    PS: i think it is a problem,for example, of pointer because they are 4 or 8 bytes based on the PC's arch!

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,681
    More likely it is the different sizes of the int type then that of pointer being different sizes.

    Use the header stdint.h to define the types used to pass data from client to server.

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  3. #3
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    383
    All FTP commands and replies are in plain text so there shouldn't be a problem with integer/pointer sizes between different architectures. It might help to look at the actual data being sent by the server and client with a packet sniffer like Wireshark. Make sure there isn't any binary data being transferred (except for the contents of a file transfer, of course).
    stahta01 likes this.

  4. #4
    Registered User
    Join Date
    May 2012
    Location
    Italy
    Posts
    52
    Do you mean something like:
    Code:
    typedef int int32_t
    typedef unsigned int uint32_t

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,669
    > How can i made these 2 programs working on different archs?
    If you can post a small program which "works" on one machine, but crashes on another, then we can tell you where you're screwing up.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    May 2012
    Location
    Italy
    Posts
    52
    I have solved
    i have changed all of my size_t to uint32_t

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Arch Linux, first install issues!
    By Annonymous in forum Linux Programming
    Replies: 4
    Last Post: 05-30-2012, 06:26 PM
  2. producing c/c++ code from flowcharts,pseudo code , algorithims
    By rohit83.ken in forum C++ Programming
    Replies: 3
    Last Post: 02-20-2008, 06:09 AM
  3. Fibonacci, my arch enemy
    By StarOrbs in forum C++ Programming
    Replies: 9
    Last Post: 03-11-2005, 07:42 AM
  4. Having trouble translating psudeo-code to real-code.
    By Lithorien in forum C++ Programming
    Replies: 13
    Last Post: 10-05-2004, 07:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21