Path: csiph.com!weretis.net!feeder4.news.weretis.net!border2.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Thu, 10 Nov 2016 23:45:50 -0600 From: Gareth Owen Newsgroups: comp.lang.c Subject: Re: Compiler design in C? References: <87lgwrzvqt.fsf@gmail.com> <87lgwrdaiu.fsf@gmail.com> <87shqz7n08.fsf@gmail.com> <362fc76e-f4aa-4c66-abfd-ea4e8d87da47@googlegroups.com> <87y40ruk7u.fsf@gmail.com> <877f8bng9u.fsf@gmail.com> Date: Fri, 11 Nov 2016 05:45:50 +0000 Message-ID: <87r36ik1rl.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:3y/0deY14Oml8R3z2JilwNpcruc= MIME-Version: 1.0 Content-Type: text/plain Lines: 49 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-2Onw4seaPQwpjr/xyqMInK6QZwPAly0d5RJlU9tRFNvNkb8b7UskGW/64mrYZ+ObHXnZb7FSqs+q0zN!DizqvSsugRbJXSX2GDZ1eu6OsUqtTTqcvfKespmZOFXMmlnHnGf7JRUkvfsnIMJck44y X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2749 Xref: csiph.com comp.lang.c:96368 jacobnavia writes: >> >> void f() >> { >> std::vector v_int(1000); >> for(auto& v: v_int) v = rand(); >> std::sort(v.begin(),v.end()); >> } >> > > 1) The c containers library is written in C89/C99, and it compiles > with gcc or msvc or clang. Or lcc if you wish, since it is written in > C. > > 2) The code would look like this: > 1 #include > 2 #include "../containers.h" > 3 > 4 int main(void) > 5 { > 6 int i; > 7 > 8 ValArrayInt * table = iValArrayInt.Create(10000); > 9 size_t siz = iValArrayInt.GetCapacity(table); > 10 for (i=0; i 11 iValArrayInt.Add(table,rand()); > 12 } > 18 iValArrayInt.Sort(table); > 19 > 25 } > > You create a table (line 8), then you fill it (line 10 to 12) and then > you sort it (line 18). Where's your #define ElementType ? ??? Do you have pre-made versions for the builtin types? What's the equivalent for a non-builtin type? > I think that line 7 should be: > 7 std::sort(v_int.begin(),v_int.end()); You're right. Brain error.