Help with porting code from Unix to Windows

Help with porting code from Unix to Windows

Post by Anish A Patanka » Sun, 04 Nov 2001 03:25:41



Hi,

We are trying to port the C code that we wrote on Unix to VC++ in Windows.
The problem is about internal functions. We had written many internal
functions( fns declared and defined and invoked from within another
function. But VC++ on Windows does not seem to support that.
We would greatly help if there is any way to solve this problem with
minimal changes to the source code.

Thanks in advance,
Anish Patankar.

============================================================================
``What makes a leader - intelligence, integrity, imagination, skill: in
brief, statecraft? Not at all. It is the fact that the man has a
following.'' - Gerald W. Johnson, American journalist (1890-1980).
============================================================================

Anish Patankar
Graduate Research Assistant
Computer Science and Engineering
State University of New York at Buffalo
Tel: O- (716) 645-6164 x 517
     H- (716) 573-6502
============================================================================

 
 
 

Help with porting code from Unix to Windows

Post by Lew Pitch » Sun, 04 Nov 2001 03:38:40


On Fri, 2 Nov 2001 13:25:41 -0500, Anish A Patankar


>Hi,

>We are trying to port the C code that we wrote on Unix to VC++ in Windows.
>The problem is about internal functions. We had written many internal
>functions( fns declared and defined and invoked from within another
>function. But VC++ on Windows does not seem to support that.

Well, if I correctly understand what you say you've done, I can tell
you that C doesn't support that either. So, you wern't using C.

To make it clear, if you wrote something like...

  void myfunction(void)
  {
         void someotherfunction(void)
         {
             printf("In someotherfunction\n");
         }

         printf("In myfunction\n");
         someotherfunction();
         printf("Back in myfunction\n");
 }

then you haven't written a C program. You've used some language that
superficially looks like C, but _isn't_ C.

The reason that this is important is that VC++ can compile C programs,

but likely cannot even recognize this wannabe-C language, and you'll
have to recode your program in C in order to get it to compile with
VC++.

If my interpretation of what you said you wrote is wrong, please let
us know. Also, give us an example of the sort of construct that VC++
is * on.

Finally, this may be a VC++ problem (and you've phrased your question
as if it were); you _should_ ask about this in one of the Microsoft
forums, rather than here in comp.unix.programmer, as VC++ isn't a Unix
tool is off-topic here.

Quote:>We would greatly help if there is any way to solve this problem with
>minimal changes to the source code.

Lew Pitcher, Information Technology Consultant, Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employer's.)

 
 
 

Help with porting code from Unix to Windows

Post by Andy Moret » Sun, 04 Nov 2001 04:25:01




Quote:

>We are trying to port the C code that we wrote on Unix to VC++ in Windows.
>The problem is about internal functions. We had written many internal
>functions( fns declared and defined and invoked from within another
>function. But VC++ on Windows does not seem to support that.
>We would greatly help if there is any way to solve this problem with
>minimal changes to the source code.

Nested functions are a gcc extension to C (look at the gcc info pages).

I suggest that either the mingw or Cygwin ports of gcc will do what you want
on Windows. Mingw uses MSVC runtimes, whereas the Cygwin port links against
the Cygwin runtime (provides fork() etc).

See http://sources.redhat.com/cygwin/ for details.

        AndyM

--
Virata, Unit 230 Cambridge Science Park, Milton Road, Cambridge CB4 0WB, UK
http://www.virata.com/  Tel: +44 1223 707400  Fax: +44 1223 707447

 
 
 

Help with porting code from Unix to Windows

Post by Lew Pitch » Sun, 04 Nov 2001 05:13:12






>>We are trying to port the C code that we wrote on Unix to VC++ in Windows.
>>The problem is about internal functions. We had written many internal
>>functions( fns declared and defined and invoked from within another
>>function. But VC++ on Windows does not seem to support that.
>>We would greatly help if there is any way to solve this problem with
>>minimal changes to the source code.

>Nested functions are a gcc extension to C (look at the gcc info pages).

Aha! I didn't know that!  :-)

In that case, before the OP tries to port his code to MSWindows, he
should recompile it with the GCC options that turn on strict ANSI
checking ("ANSI" and "pedantic", IIRC), so that he can find and clean
out all the other GCC-dependant constructs.

Of course, the OP could just install the DOS/Windows Gnu C (DJGCC or
Cygwin) and recompile his code under MSWindows. However, this would
tie him to specific extensions supported by specific compilers, and
severly limit the portability of his code (suppose he wants to port
the code to the OS/390 by compiling it with IBM's native C compiler?).

[snip]

Lew Pitcher, Information Technology Consultant, Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employer's.)

 
 
 

Help with porting code from Unix to Windows

Post by Barry Margoli » Sun, 04 Nov 2001 05:20:05




>Of course, the OP could just install the DOS/Windows Gnu C (DJGCC or
>Cygwin) and recompile his code under MSWindows. However, this would
>tie him to specific extensions supported by specific compilers, and
>severly limit the portability of his code (suppose he wants to port
>the code to the OS/390 by compiling it with IBM's native C compiler?).

But they already *are* tied to specific extensions supported by specific
compilers.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

Help with porting code from Unix to Windows

Post by Lew Pitch » Sun, 04 Nov 2001 05:37:35






>>Of course, the OP could just install the DOS/Windows Gnu C (DJGCC or
>>Cygwin) and recompile his code under MSWindows. However, this would
>>tie him to specific extensions supported by specific compilers, and
>>severly limit the portability of his code (suppose he wants to port
>>the code to the OS/390 by compiling it with IBM's native C compiler?).

>But they already *are* tied to specific extensions supported by specific
>compilers.

My point exactly.

The OP has a choice: clean up his code to bring it up to the standard
for portable C, or leave his code alone and be stuck to only those
platforms that run the particular level of GNU C he used on Unix.

If it were me, I'd clean up the code. But the OP isn't me, and he
already said that he wants "minimal changes to the source code".  Of
course, he also said that he wants to compile the code under VC++, so
that puts him between a rock and a hard place; two conflicting
requirements.

Lew Pitcher, Information Technology Consultant, Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employer's.)

 
 
 

1. Porting C code from PC/WINDOWS to UNIX

I am looking for a company that can port C library code from Windows/PC
to a number of different UNIX platforms (HP, SCO, SUN-OS).  There is no
user interface that need to be ported.  Can anyone suggest a company
that does this type of work?

Thanks

-~-~
Dave Schaller    3M   (00-1) 203-949-6417   3M Triminet- 340-6417

2. Q-Logic Fast-SCSI ISA

3. abt porting code from windows to unix

4. YDL 2.0 working

5. Porting C/C++ code from WINDOWS to UNIX

6. XF86Config for MAG DX17F

7. Can someone help me to port this short qbasic code to C (unix C)

8. Cannot compile on YDL 2.1

9. HELP, Porting Sun C code to SGI C code (ftime and timeb.h)

10. Help needed on Porting from Unix to Windows !!!

11. Help for Porting Application from Unix To Windows NT !!

12. HELP: Porting INGRES/Windows 4GL (UNIX) to WinNT

13. Help... porting Windows Events to Solaris (Unix Sockets?)