Migrating C Code from OS2 to Windows

Discussion in 'C Programming' started by skulkrinbait@googlemail.com, Jul 19, 2006.

  1. Guest

    Hello, I need some help please.

    I need to migrate some applications from OS2 to Windows, the source
    code is C. I believe this can be done using Lex and Yacc and have
    installed Cygwin with Flex and Bison which I believe are compatible but

    I'm having trouble getting Flex to process the C file. I assume that
    I need to write some rules for Flex to use but as I'm not familiar
    with C I've no idea what the rules should be. Apologies for sounding
    like a dunce here but any help would be appreciated.
    , Jul 19, 2006
    #1
    1. Advertising

  2. pemo Guest

    wrote:
    > Hello, I need some help please.
    >
    > I need to migrate some applications from OS2 to Windows, the source
    > code is C. I believe this can be done using Lex and Yacc and have
    > installed Cygwin with Flex and Bison which I believe are compatible
    > but
    >
    > I'm having trouble getting Flex to process the C file. I assume that
    > I need to write some rules for Flex to use but as I'm not familiar
    > with C I've no idea what the rules should be. Apologies for sounding
    > like a dunce here but any help would be appreciated.



    What makes you think that you need Flex etc, what does the OS/2 code
    do/look-like?

    --
    ==============
    Not a pedant
    ==============
    pemo, Jul 19, 2006
    #2
    1. Advertising

  3. Chris Dollin Guest

    wrote:

    > Hello, I need some help please.
    >
    > I need to migrate some applications from OS2 to Windows, the source
    > code is C. I believe this can be done using Lex and Yacc


    What's wrong with using a C compiler?

    If there's something /wrong/ with the C code, you'll get better
    help if you tell us what the problem is, rather than what your
    attempt at a solution is.

    If you're not familiar with C, and the code wasn't written with
    portability in mind, moving it from one platform to another could
    be rather tricky.

    --
    Chris "endian sizeof filename UB blackhole" Dollin
    A rock is not a fact. A rock is a rock.
    Chris Dollin, Jul 19, 2006
    #3
  4. jacob navia Guest

    a écrit :
    > Hello, I need some help please.
    >
    > I need to migrate some applications from OS2 to Windows, the source
    > code is C. I believe this can be done using Lex and Yacc and have
    > installed Cygwin with Flex and Bison which I believe are compatible but
    >
    > I'm having trouble getting Flex to process the C file. I assume that
    > I need to write some rules for Flex to use but as I'm not familiar
    > with C I've no idea what the rules should be. Apologies for sounding
    > like a dunce here but any help would be appreciated.
    >


    This is a mistake. Lex and Yacc are not needed at all.
    What you have to do is

    1) Find somebody that has a clue. If you think that lex/yacc
    will port a C application from OS2 to Unix it means you
    have no clue but really ABSOLUTELY NOTHING!

    2) Pay him/her what he/she wants (you have no choice anyway)
    jacob navia, Jul 19, 2006
    #4
  5. David West Guest

    Having no knowledge of migrating applications across OS I was given the
    advice (rightly or wrongly) that I needed to use Lex and Yacc or
    similar to do the job as well as a C compiler. My understanding, which
    could well be wrong is that C differs slightly on the different OS,
    hence the need for some kind of "translation".

    The code is a compiler for a bespoke language called "AB" which
    resembles a form of BASIC. A small excerpt of the code follows (the
    whole thing is 42kb), thanks for your help:

    BOOL CheckCancel( MODULE_TYPE iCompiler )
    {
    BOOL bRtn = FALSE;


    if ( pShared->RelMechData.bCancelRelease )
    {
    /*
    * The compilation process has been cancelled.
    */

    if ( iCompiler == MBuildRelease )
    {
    /* Do not abort this thread, since this is the Main Build
    Release Thread... */

    AddStatus( INFORMATION , "Abort !" , "Compilation process
    aborted by operator" );
    }
    else
    {
    /* Exit this thread, this is the compiler thread... */

    AddStatus( FATAL , "Abort !" , "Compilation process
    aborted by operator" );
    }

    bRtn = TRUE;
    }

    return bRtn;
    }

    -----------

    pemo wrote:

    >
    >
    > What makes you think that you need Flex etc, what does the OS/2 code
    > do/look-like?
    >
    > --
    > ==============
    > Not a pedant
    > ==============
    David West, Jul 19, 2006
    #5
  6. Chris Dollin Guest

    David West wrote:

    > Having no knowledge of migrating applications across OS I was given the
    > advice (rightly or wrongly) that I needed to use Lex and Yacc or
    > similar to do the job as well as a C compiler.


    Unless there's something else going on that you haven't mentioned yet,
    this seems unlikely.

    > My understanding, which
    > could well be wrong is that C differs slightly on the different OS,
    > hence the need for some kind of "translation".


    Such translation is probably best done by people, and done in such a
    way as to reduce or eliminate the code that "needs to be different".

    Unless you understand what the differences /are/, automated
    assistance isn't likely to help.

    > The code is a compiler for a bespoke language called "AB" which
    > resembles a form of BASIC.


    It's /possible/ that whoever said you needed Lex and Yacc thought
    that you'd need to rewrite the code to use them as part of the
    migration. (You very likely don't.) Or it's possible that the AB
    compiler is written using them (Lex and Yacc, or Flex and Bison,
    turn descriptions of languages into C code [well, tables for C code])
    and migrating it will need to migrate the lexis and grammar.

    If that's so, comp.lang.c is the wrong place to ask about the
    Lex and Yacc bits. There are more appropriate newsgroups;
    I'd try asking in comp.programming or comp.compilers.

    The C code you present looks fine (assuming that all the undefined
    names are defined in suitable header files). 42Kb of code isn't
    much, unless you really meant 42K /lines/. The problems will
    come when you try and compiler it, and then when you try and
    run it (hopefully there are tests suites you can run to make
    sure it's migrated reasonably safely).

    --
    Chris "seeker" Dollin
    "I'm still here and I'm holding the answers" - Karnataka, /Love and Affection/
    Chris Dollin, Jul 19, 2006
    #6
  7. In article <e9lck5$jfa$>,
    Chris Dollin <> wrote:

    >Or it's possible that the AB
    >compiler is written using them (Lex and Yacc, or Flex and Bison,
    >turn descriptions of languages into C code [well, tables for C code])
    >and migrating it will need to migrate the lexis and grammar.


    In this case you will quite likely be able to generate the C code on
    the old OS and just copy it over.

    -- Richard
    Richard Tobin, Jul 19, 2006
    #7
  8. pemo Guest

    David West wrote:
    > Having no knowledge of migrating applications across OS I was given
    > the advice (rightly or wrongly) that I needed to use Lex and Yacc or
    > similar to do the job as well as a C compiler. My understanding,
    > which could well be wrong is that C differs slightly on the different
    > OS, hence the need for some kind of "translation".
    >
    > The code is a compiler for a bespoke language called "AB" which
    > resembles a form of BASIC. A small excerpt of the code follows (the
    > whole thing is 42kb), thanks for your help:
    >
    > BOOL CheckCancel( MODULE_TYPE iCompiler )
    > {
    > BOOL bRtn = FALSE;
    >
    >
    > if ( pShared->RelMechData.bCancelRelease )
    > {
    > /*
    > * The compilation process has been cancelled.
    > */
    >
    > if ( iCompiler == MBuildRelease )
    > {
    > /* Do not abort this thread, since this is the Main Build
    > Release Thread... */
    >
    > AddStatus( INFORMATION , "Abort !" , "Compilation process
    > aborted by operator" );
    > }
    > else
    > {
    > /* Exit this thread, this is the compiler thread... */
    >
    > AddStatus( FATAL , "Abort !" , "Compilation process
    > aborted by operator" );
    > }
    >
    > bRtn = TRUE;
    > }
    >
    > return bRtn;
    > }
    >
    > -----------
    >
    > pemo wrote:
    >
    >>
    >>
    >> What makes you think that you need Flex etc, what does the OS/2 code
    >> do/look-like?


    I suspect that the only major problem you might have is if the code uses
    OS/2 APIs and that these will have to be ported to use Windows' API calls.

    Years ago I work on a 'thing' called WLO [pronounced /Willow/ - The
    *W*indows *L*ibraries for *O*S/2] - ok, it went the other way, but the
    /mapping layer/ might be of interest to you, e.g., the libraries would
    re-direct OS/2 [actually GPI] APIs like gpiFullArc to the Windows' Elipse
    function in GDI. The idea here was that one could port a Windows app to
    OS/2 via simply linking to these replacement libraries. Of course, you'll
    most likely not find something that does this in the other direction -
    dunno, been away from this stuff for some time now. So, you'll have to
    /port/ any API calls manually - most I suspect will now [2K, XP etc] move
    easily - but that's what I always think!

    --
    ==============
    Not a pedant
    ==============
    pemo, Jul 19, 2006
    #8
  9. Al Balmer Guest

    On 19 Jul 2006 14:00:57 GMT, (Richard Tobin)
    wrote:

    >In article <e9lck5$jfa$>,
    >Chris Dollin <> wrote:
    >
    >>Or it's possible that the AB
    >>compiler is written using them (Lex and Yacc, or Flex and Bison,
    >>turn descriptions of languages into C code [well, tables for C code])
    >>and migrating it will need to migrate the lexis and grammar.

    >
    >In this case you will quite likely be able to generate the C code on
    >the old OS and just copy it over.
    >

    OK for the initial port, but not for maintenance. I'd port the highest
    level source available.

    --
    Al Balmer
    Sun City, AZ
    Al Balmer, Jul 19, 2006
    #9
  10. jacob navia <> writes:
    > a écrit :
    >> Hello, I need some help please.
    >> I need to migrate some applications from OS2 to Windows, the source
    >> code is C. I believe this can be done using Lex and Yacc and have
    >> installed Cygwin with Flex and Bison which I believe are compatible but
    >> I'm having trouble getting Flex to process the C file. I assume that
    >> I need to write some rules for Flex to use but as I'm not familiar
    >> with C I've no idea what the rules should be. Apologies for sounding
    >> like a dunce here but any help would be appreciated.
    >>

    >
    > This is a mistake. Lex and Yacc are not needed at all.
    > What you have to do is
    >
    > 1) Find somebody that has a clue. If you think that lex/yacc
    > will port a C application from OS2 to Unix it means you
    > have no clue but really ABSOLUTELY NOTHING!
    >
    > 2) Pay him/her what he/she wants (you have no choice anyway)


    Maybe. Since, as the OP said later, the C application is a compiler
    for a custom language (called "AB"), lex and yacc might well be part
    of the solution.

    Using lex and yacc to port C code in general is absurd, but it could
    make sense in this particular case. (No offense, jacob; I'm sure you
    hadn't seen the OP's followup when you posted this.)

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Jul 19, 2006
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jeff
    Replies:
    0
    Views:
    352
  2. Replies:
    2
    Views:
    305
    Richard Herring
    Jul 19, 2006
  3. kerravon
    Replies:
    0
    Views:
    433
    kerravon
    Aug 23, 2009
  4. Kurt Euler
    Replies:
    2
    Views:
    94
    Csaba Henk
    Feb 28, 2005
  5. Shmuel (Seymour J.) Metz

    Mystery message: Undefined subroutine &OS2::Bootdrive

    Shmuel (Seymour J.) Metz, Sep 22, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    104
    Shmuel (Seymour J.) Metz
    Sep 23, 2004
Loading...

Share This Page