Tool to port / convert SAS C to ANSI C???

Posted on 2005-04-14
Last Modified: 2010-04-15
Does anyone have a tool that converts old-style C Code to ANSI C for use with the GCC compiler?  If no tool or conversion script exists, is it feasible to create one?  I'm looking for the types of issues (syntax, obsolete header files, data types, etc) that I need to be aware of to port a HUGE amount of code over to work with a new system that uses ANSI C and compile successfully.  Thanks in advance!!!
Question by:wmv678

    Author Comment

    Also, I believe the current "old-style" C code is SAS/C.
    LVL 30

    Expert Comment

    Hi wmv678,
    > >converts old-style C Code to ANSI C

    The old-style C should still work with GCC compiler.

    David Maisonave :-)
    LVL 22

    Accepted Solution

    gcc can accept old-style C.  But a lot of old-style C may have been crafted to work with a particular compiler and it's quirks and features.

    A lot of things can break-- things like the size of ints, the size of pointers,  near and far memory models, direct int 21h or BIOS calls, structure sizes and padding..   You basically have to go over the code and see if it still compiles, links, and runs.  In typical old code you'll find some glitch every 20 to 30 lines.


    Author Comment

    There are certainly a lot of quirks.  The orginal code is the Mainframe Version of SAS/c (MVS?), and the goal is to move it to a new Linux platform running the G++ compiler.  Sorry for stating GCC earlier, but G++ should handle anything GCC can handle anyway, right?  I'm looking for more specific examples if changes that need to be made to the code to get it to run correctly, so that we can develop a set of rules to follow as we port over the code.  I understand that the "rules" won't capture every little quirk and situation, but it should be a start, or even better, the basis for a script that does a first pass over all the code, because we have over a million lines.

    For example, current compile issues:

    Mainframe uses (| |)     ...    needs to be [ ]

    int f(x)               needs to be            int f(char * x)  
      char * x
    LVL 30

    Expert Comment

    >>G++ should handle anything GCC can handle anyway, right?

    Just make sure you don't change the name of the file extension.
    Dont' change file name from foo.c to foo.cpp

    If you keep the file name to a C file extension, the above Old-Style C should compile.
    LVL 20

    Expert Comment

    wmv678  -

    This old question needs to be finalized — accept an answer, split points, or get a refund.  For information on your options, please see

    Once more than 21 days have passed with no new responses posted, a question is considered abandoned.  If you do nothing, I will make a recommendation to the moderators on its resolution in approximately 4 to 14 days.

    EXPERTS -  I would appreciate any comments that would help me in making a recommendation.

    At this point, I'm concerned that the reassurances the gcc will handle the code are too optimistic. It is not clear that the experts who have responded have dealt with this particular variant of C, so they have given general, rather than specific, advice. It's not bad advice, it just doesn't help very much. The decision is up to wmv678, but I'll likely recommend, if he or she does nothing, for PAQ/Refund.

    EE Cleanup Volunteer

    Author Comment


    I agree with your last statement.  If anything, I would award grg99 partial points.  However, the other comments were inaccurate and not useful.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
    Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
    The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now