Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Reason for segmentation violation Date: Fri, 12 Jun 2015 08:56:48 -0700 Organization: None to speak of Lines: 52 Message-ID: <87ioashqdb.fsf@kst-u.example.com> References: <869bae8d-e318-4e1c-865b-3c5890304279@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="9be37d943435275679235b07c7947eef"; logging-data="8039"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WW/L569ZaUgAvqrpcSzEf" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:GnU8sTX6wgervG7FcnwRDo1+lqI= sha1:eV+EFW1QUFdxmnK4a60rfrjG6UA= Xref: csiph.com comp.lang.c:63218 Richard Heathfield writes: > On 12/06/15 07:42, Morten W. Petersen wrote: >> On Friday, June 12, 2015 at 4:58:56 AM UTC+2, Barry Schwarz wrote: >> >>> >So, for example having a function which returns long, you're >>> saying that I don't need to cast an integer (presumably) to long? >>> This will just automagically work? >>> >>> Download a copy of the draft C standard (my copy is called n1570) and >>> read up on "Conversions". >> >> Well, this brings up another interesting point. I'd like to keep >> things as simple and portable as possible. What version of C is >> it a good idea to aim for, what version of C has features that it >> would be self-defeating not to make use of? > > Well, around here them's fitin' woids, and you'll get a hundred > different answers, all of them wrong except mine. :-) > > The simplest, portablest(tm) "version" of C is the common subset of > C90, C99, and C11. That's what I use. The features it has that it > would be self-defeating not to make use of are "it works everywhere" > and "it breaks nowhere". [...] That's certainly a valid approach, but it's not the only one. I think you said you're using gcc. gcc has good (but probably not 100% complete) support for C99, and some support for C11. Each of the newer standards includes a foreword that lists the features that were added relative to the previous standard. If you find those features useful, you *probably* won't have any problems using them. As Richard correctly points out, using C99- or C11-specific features will limit the portability of your code. In practice, the biggest issue is likelyi to be Microsoft's compiler, which has good support for C90 but very poor support for C99. Some compilers for embedded systems might also have poor support for later standards. You'll have to decide, based on your own requirements, whether the convenience of any newer features is worth the loss of portability. Drafts of the C99 and C11 standards are available at no cost. C99: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf C11: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"