Thread: Porting code form *nix to win

  1. #1
    Merlion
    Guest

    Question Porting code form *nix to win

    Should be a simple question. I code mainly for *nix, tho now starting to port a lot of m code to win32. I wrote this code that basically binds a port to a shell in *nix, so now I'm getting it to work on win32. So far, everythings fine, as I've done this a few times now. But in the *nix code, I call fork() a couple times, as I do with setpgrp(). When I compile this in win32, I get the following error: undefined reference to _fork (same with setpgrp).. How come? Do I need to do a #define _fork fork?

    Thanks

    -Merl

  2. #2
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Um...C code is really system dependant. What you would want to do if you wanted code on win and *nix, then you would have to do conditional compilation. For instance:
    Code:
    #ifdef _UNIX_
    /*** ETC ***/
    #else
    /*** ETC ***/
    Understand what I mean?

    --Garfield
    1978 Silver Anniversary Corvette

  3. #3
    Merlion
    Guest

    Garfield:

    Yeah, I totally understand. For example, I start my portscanner that way:

    #ifdef _WIN32
    #include "sockwin.h"
    #else
    #inlcude "socknix.h"
    #endif

    But I still don't understand why the reference to fork is _fork?

    See what I mean? I guess I don't know HOW to code this for windows..?

    -Merlion

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  2. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 01:37 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  4. Seems like correct code, but results are not right...
    By OmniMirror in forum C Programming
    Replies: 4
    Last Post: 02-13-2003, 01:33 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM