comp.lang.c.moderated
  Home FAQ Contact Sign in
comp.lang.c.moderated only
 
Advanced search
June 2007
motuwethfrsasuw
    123 22
45678910 23
11121314151617 24
18192021222324 25
252627282930  26
2007
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.c.moderated Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Simple SLEEP macro?         


Author: gamename
Date: Jun 11, 2007 12:25

Hi,

I just inherited a substantial number of source files with this in
them:
#ifdef _WIN32
Sleep(2000);
#else
sleep(2);
#endif

Being new to C, I'm trying to figure out if this can be consolidated
into a simple macro instead of peppering this all over the place.
Anyone have any examples?

TIA,
-T
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
no comments
  Re: how can i generate warnings for implicit casts that lose bits?         


Author: robert bristow-johnson
Date: Jun 11, 2007 12:25

On Jun 8, 10:33 am, "Douglas A. Gwyn" null.net> wrote:
> robert bristow-johnson wrote:
>> isn't there a way to get this thing to complain when i do an
>> assignment (without explicit casting) of a 32-bit int to a 16-bit
>> int? we know that bits can be potentially dumped in such an
>> assignment. why can't i get this thing to warn me?
>
> That's a job for a tool like "lint".

actually, i think not. this is a compiler issue when an implicit type
conversion (between different flavors of int) *may* cause a change of
value. when building a big project, if you want to impose a
discipline on a bunch of different programmers to not do sloppy
actions that might loose bits somewhere where you won't be looking
(because it is not apparent that any such values were changed in an
expressed equality), these *potential* problems should be flagged in
the build. then you can go into the code, examine it, and if you
think the conversion is kosher, put an explicit cast on it. then the
warning goes away.
Show full article (1.99Kb)
no comments
  how can i generate warnings for implicit casts that lose bits?         


Author: robert bristow-johnson
Date: Jun 7, 2007 12:04

presently using linux gcc:

$ gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/usr/share/info --enable-shared --enable-threads=posix --
enable-checking=release --with-system-zlib --enable-__cxa_atexit --
disable-libunwind-exceptions --enable-libgcj-multifile --enable-
languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --
disable-dssi --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.1 20060525 (Red Hat 4.1.1-1)

i run it on this program:
FILE: hello.c

//
// $ gcc -Wconversion -o hello hello.c
// $ hello
//
Show full article (2.05Kb)
2 Comments
  Re: Questions about memory management         


Author: HS
Date: Jun 1, 2007 05:21

I would just like to say thank you to both of you for your comments on
my code and for the answers to my questions. I will be rewriting the
code to be more robust and adding a few features. After I finish I
will be reposting so hopefully some other people can learn like I have
from this program and your posts.
-Thankyou
--HS
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
no comments