delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/07/11/04:59:16

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE
X-Spam-Check-By: sourceware.org
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=ejLhgUK78UbaYIrRERRTUrzYcF3DI4p+Ef1F8l/Jn0M=; b=On9GjDRQjyDVckClT4B2rIr4+Y7btt9QzDefOWYj+aGx+g2uUzqNyrEZiYTb5FLICY d46cMJHzKBlzdfQElBY7Z66nENcd8IvjdUM0lj8TYeQNGURG89tz0tE237vspPRG+qVc 6xQfHcJmJ0hVZTSpeW91Zib8h7nInYvhs5ItSuLNEulslYGEENBtclJtV3CJCB1g+fVG NaTEHTPe3MlwTBoA4uiuodDFny/vEmz9zVswgcXKGGsYK0eUIzquOAbs1UmBGrP8qGb2 6QFNz1dcCMvaEok20coK7e7nSwJpTLD/lXsW1STM0HbQilK0Ey28DCVJZcFfJkRMuPLe G2KQ==
MIME-Version: 1.0
Date: Wed, 11 Jul 2012 10:58:46 +0200
Message-ID: <CAEfSKhekKJUxVo1Nh08O4Xa2rkm788RX-f9HMr-a4DLz2WBtEA@mail.gmail.com>
Subject: sleep removed ?
From: Herbert Groot Jebbink <herbert AT groot DOT jebbink DOT nl>
To: cygwin AT cygwin DOT com
X-Gm-Message-State: ALoCoQkWShJ4T2DN4c03k8FT/w0OANZ9S6pzRJNoPTZ72NczznJ6mO5/hqLUGYpKqhaGf8kz9CX6
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Hi,

I was asked to make a little change in a c program from 10+ years ago.
The change itself was not the problem, but the environment is changed
and I did have compile problems.

Old: Cygwin: 1.3.2  (0.39/3/2)  2001-05-20 23:28
New: Cygwin: 1.7.15 (0.260/5/3) 2012-05-09 10:25

The problem was the sleep statement, that was not working anymore:

     /home/herbert/project/main.c:124: undefined reference to `_sleep'

Below (the relevant parts of) the old code:

    #include <unistd.h>

    /* Extra defenition for avoiding warning at compiling */
    #ifndef UNIX
        unsigned int sleep(int); /* somehow, compiler don't understand
it completely */
    #endif

    #ifdef UNIX
        sleep(1);
    #else
        sleep(1000);
    #endif

I changed it into:

    #ifdef _WIN32
    # include <windows.h>
    # define sleep(x) Sleep(1000 * x)
    #else
    # include <unistd.h>
    #endif

    sleep(1);

It compiles now, but is it also correct ?

The executable did go from 251 KB to 1034 KB, is this caused by
windows.h that is now included and not in the old version ?

Kind Regards, Herbert

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019