MESSAGE
DATE | 2016-11-18 |
FROM | ruben safir
|
SUBJECT | Subject: [Learn] C++ workshop and usenet responses
|
From learn-bounces-at-nylxs.com Fri Nov 18 21:12:37 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 18C94161314; Fri, 18 Nov 2016 21:12:37 -0500 (EST) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from [10.0.0.62] (flatbush.mrbrklyn.com [10.0.0.62]) by mrbrklyn.com (Postfix) with ESMTP id EC11F161312 for ; Fri, 18 Nov 2016 21:12:31 -0500 (EST) References: <582c90d5$0$1849$e4fe514c-at-newszilla.xs4all.nl> <0086c9c2-1813-4d42-b825-6affc64bed5a-at-googlegroups.com> <20161116073842.7d9f2952-at-maxa-pc> <0PudnTFUMuaworHFnZ2dnUU78K_NnZ2d-at-giganews.com> <887c4e1c-514d-4726-942d-f5c59099fa8a-at-googlegroups.com> To: learn-at-nylxs.com From: ruben safir X-Forwarded-Message-Id: <%hJXz.447$gd1.142-at-fx01.iad> <582c90d5$0$1849$e4fe514c-at-newszilla.xs4all.nl> <0086c9c2-1813-4d42-b825-6affc64bed5a-at-googlegroups.com> <20161116073842.7d9f2952-at-maxa-pc> <0PudnTFUMuaworHFnZ2dnUU78K_NnZ2d-at-giganews.com> <887c4e1c-514d-4726-942d-f5c59099fa8a-at-googlegroups.com> Message-ID: Date: Fri, 18 Nov 2016 21:12:31 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------4FA1628384734F4ADFC1D36A" Subject: [Learn] C++ workshop and usenet responses X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
This is a multi-part message in MIME format. --------------4FA1628384734F4ADFC1D36A Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit
See the useful PNG libs, clarification of #include, and more
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="hidden static.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="hidden static.eml"
Path: reader2.panix.com!panix!not-for-mail From: Popping mad Newsgroups: comp.lang.c++ Subject: hidden static Date: Sat, 19 Nov 2016 01:49:12 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: NNTP-Posting-Host: www.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reader2.panix.com 1479520152 17183 96.57.23.82 (19 Nov 2016 01:49:12 GMT) X-Complaints-To: abuse-at-panix.com NNTP-Posting-Date: Sat, 19 Nov 2016 01:49:12 +0000 (UTC) User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT b8fc14e git.gnome.org/git/pan2) Xref: panix comp.lang.c++:1125334
I've a declared static as a public member of an object but it doesn't seem to show up in the compiler
/home/ruben/src/test_static/test.cpp|22| undefined reference to `blah::A::here'
If I put it on top it errors are a private member. When I move it to public, it is not being seen
The three test case files look like this
test.cpp
18 #include "test.h" 19 #include 20 namespace blah{ 21 void A::read(int in){ 22 A::here = in; 23 std::cout << here << std::endl; 24 } 25 }
test.h
1 namespace blah{ 2 class A{ 3 public: 4 static int here; 5 A(int in=0){ 6 here = in; 7 }; 8 void read(int); 9 }; 10 11 } ~
main.cpp 18 #include "test.h" 19 #include 20 namespace std{ 21 22 int main(int argc, char** argv){ 23 24 blah::A* a = new blah::A{9}; 25 cout << a->here << endl; 26 return 0; 27 } 28 29 } ~ makefile
1 CXX:=g++ 2 CXXFLAGS:=-Wall -ggdb -pg -pthread 3 4 LDFLAGS:=-L/usr/local/lib/mysql -lmysqlpp -lmysqlclient 5 6 test : test.o main.o 7 ${CXX} ${CXXFLAGS} -o testme test.o main.o 8 9 main.o : main.cpp 10 ${CXX} ${CXXFLAGS} -o main.o -c main.cpp 11 12 test.o : test.cpp test.h 13 ${CXX} ${CXXFLAGS} -c test.cpp 14 15 clean : 16 rm testme *.o make.deps 17 touch *.cpp *.h 18 19 include make.deps 20 make.deps: *.cpp ; gcc -M *.cpp >$-at- ~
I need an extern? 1 || g++ -Wall -ggdb -pg -pthread -o testme test.o main.o 2 || /usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../lib/gcrt1.o: In function `_start': 3 || (.text+0x20): undefined reference to `main' 4 || test.o: In function `blah::A::read(int)': 5 /home/ruben/src/test_static/test.cpp|22| undefined reference to `blah::A::here' 6 /home/ruben/src/test_static/test.cpp|23| undefined reference to `blah::A::here' 7 || main.o: In function `std::main(int, char**)': 8 /home/ruben/src/test_static/main.cpp|25| undefined reference to `blah::A::here' 9 || main.o: In function `blah::A::A(int)': 10 /home/ruben/src/test_static/test.h|6| undefined reference to `blah::A::here'
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="guaranteeing const.eml" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="guaranteeing const.eml"
Path: reader2.panix.com!panix!not-for-mail From: Popping mad Newsgroups: comp.lang.c++ Subject: guaranteeing const Date: Fri, 18 Nov 2016 18:39:10 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: NNTP-Posting-Host: www.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reader2.panix.com 1479494350 17183 96.57.23.82 (18 Nov 2016 18:39:10 GMT) X-Complaints-To: abuse-at-panix.com NNTP-Posting-Date: Fri, 18 Nov 2016 18:39:10 +0000 (UTC) User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT b8fc14e git.gnome.org/git/pan2) Xref: panix comp.lang.c++:1125314
How does one do this without losing the const
}; /* constructor */ Node ( const Node &other ){ parent(other.parent()) const; right(other.right() const); left(other.left() const); value(other.value() const); max(other.max()) const; }; /* copy constructor */ ~Node (){}; /* destructor */
msort.h|41 col 25| error: passing ‘const maxpath::Node’ as ‘this’ argument discards qualifiers [-fpermissive]
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: guaranteeing const.eml" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="Re: guaranteeing const.eml"
Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!168.235.88.217.MISMATCH!feeder.erje.net!2.us.feeder.erje.net!weretis.net!feeder6.news.weretis.net!news.glorb.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!post02.iad.highwinds-media.com!fx44.iad.POSTED!not-for-mail Subject: Re: guaranteeing const Newsgroups: comp.lang.c++ References: From: bitrex User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: X-Complaints-To: abuse-at-frugalusenet.com NNTP-Posting-Date: Fri, 18 Nov 2016 20:06:17 UTC Organization: frugalusenet - www.frugalusenet.com Date: Fri, 18 Nov 2016 15:06:16 -0500 X-Received-Bytes: 1626 X-Received-Body-CRC: 3039229739 Xref: panix comp.lang.c++:1125316
On 11/18/2016 01:39 PM, Popping mad wrote: > How does one do this without losing the const > > > }; /* constructor */ > Node ( const Node &other ){ > parent(other.parent()) const; > right(other.right() const); > left(other.left() const); > value(other.value() const); > max(other.max()) const; > }; /* copy constructor */ > ~Node (){}; /* > destructor */ > > > msort.h|41 col 25| error: passing ‘const maxpath::Node’ as ‘this’ > argument discards qualifiers [-fpermissive] >
Probably because your methods "parent", "right", etc. aren't declared "const."
What compiler does this compile under? I'm surprised putting "const" after a function call like that isn't a syntax error.
If you have to do it this way probably best to create a local non-const copy of Node in the copy ctr and pass it in
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: guaranteeing const.eml" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="Re: guaranteeing const.eml"
Path: reader2.panix.com!panix!news.linkpendium.com!news.linkpendium.com!news.glorb.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!post02.iad.highwinds-media.com!fx01.iad.POSTED!not-for-mail Subject: Re: guaranteeing const Newsgroups: comp.lang.c++ References: From: bitrex User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <%hJXz.447$gd1.142-at-fx01.iad> X-Complaints-To: abuse-at-frugalusenet.com NNTP-Posting-Date: Fri, 18 Nov 2016 20:13:47 UTC Organization: frugalusenet - www.frugalusenet.com Date: Fri, 18 Nov 2016 15:13:47 -0500 X-Received-Bytes: 1852 X-Received-Body-CRC: 2300729633 Xref: panix comp.lang.c++:1125317
On 11/18/2016 03:06 PM, bitrex wrote: > On 11/18/2016 01:39 PM, Popping mad wrote: >> How does one do this without losing the const >> >> >> }; /* constructor */ >> Node ( const Node &other ){ >> parent(other.parent()) const; >> right(other.right() const); >> left(other.left() const); >> value(other.value() const); >> max(other.max()) const; >> }; /* copy constructor */ >> ~Node (){}; /* >> destructor */ >> >> >> msort.h|41 col 25| error: passing ‘const maxpath::Node’ as ‘this’ >> argument discards qualifiers [-fpermissive] >> > > Probably because your methods "parent", "right", etc. aren't declared > "const." > > What compiler does this compile under? I'm surprised putting "const" > after a function call like that isn't a syntax error. > > If you have to do it this way probably best to create a local non-const > copy of Node in the copy ctr and pass it in
Well, wait. That might be bad...
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: guaranteeing const.eml" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="Re: guaranteeing const.eml"
Path: reader2.panix.com!panix!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: red floyd Newsgroups: comp.lang.c++ Subject: Re: guaranteeing const Date: Fri, 18 Nov 2016 12:14:35 -0800 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 18 Nov 2016 20:14:04 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="2f9fe2bf271e50e57ba9aad52dab58d5"; logging-data="20042"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX1/lbZlfB/h2CjZ1RcEc3bX+hi9+qisWTWw=" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 In-Reply-To: Cancel-Lock: sha1:apxiww1bqdiPz79T0ukqntXxQoI= Xref: panix comp.lang.c++:1125318
On 11/18/2016 12:06 PM, bitrex wrote: > On 11/18/2016 01:39 PM, Popping mad wrote: >> How does one do this without losing the const >> >> >> }; /* constructor */ >> Node ( const Node &other ){ >> parent(other.parent()) const; >> right(other.right() const); >> left(other.left() const); >> value(other.value() const); >> max(other.max()) const; >> }; /* copy constructor */ >> ~Node (){}; /* >> destructor */ >> >> >> msort.h|41 col 25| error: passing ‘const maxpath::Node’ as ‘this’ >> argument discards qualifiers [-fpermissive] >> > > Probably because your methods "parent", "right", etc. aren't declared > "const." > > What compiler does this compile under? I'm surprised putting "const" > after a function call like that isn't a syntax error. > > If you have to do it this way probably best to create a local non-const > copy of Node in the copy ctr and pass it in
I *THINK* he's trying to use an initializer list. I've already told him his syntax for that is wrong.
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: guaranteeing const.eml" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="Re: guaranteeing const.eml"
Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!168.235.88.217.MISMATCH!feeder.erje.net!2.us.feeder.erje.net!weretis.net!feeder6.news.weretis.net!news.glorb.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!post02.iad.highwinds-media.com!fx02.iad.POSTED!not-for-mail Subject: Re: guaranteeing const Newsgroups: comp.lang.c++ References: From: bitrex User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: X-Complaints-To: abuse-at-frugalusenet.com NNTP-Posting-Date: Fri, 18 Nov 2016 20:16:48 UTC Organization: frugalusenet - www.frugalusenet.com Date: Fri, 18 Nov 2016 15:16:47 -0500 X-Received-Bytes: 2039 X-Received-Body-CRC: 2466086407 Xref: panix comp.lang.c++:1125319
On 11/18/2016 03:14 PM, red floyd wrote: > On 11/18/2016 12:06 PM, bitrex wrote: >> On 11/18/2016 01:39 PM, Popping mad wrote: >>> How does one do this without losing the const >>> >>> >>> }; /* constructor */ >>> Node ( const Node &other ){ >>> parent(other.parent()) const; >>> right(other.right() const); >>> left(other.left() const); >>> value(other.value() const); >>> max(other.max()) const; >>> }; /* copy constructor */ >>> ~Node (){}; /* >>> destructor */ >>> >>> >>> msort.h|41 col 25| error: passing ‘const maxpath::Node’ as ‘this’ >>> argument discards qualifiers [-fpermissive] >>> >> >> Probably because your methods "parent", "right", etc. aren't declared >> "const." >> >> What compiler does this compile under? I'm surprised putting "const" >> after a function call like that isn't a syntax error. >> >> If you have to do it this way probably best to create a local non-const >> copy of Node in the copy ctr and pass it in > > I *THINK* he's trying to use an initializer list. I've already told him > his syntax for that is wrong. >
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: guaranteeing const.eml" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="Re: guaranteeing const.eml"
Path: reader2.panix.com!panix!goblin2!goblin.stu.neva.ru!peer01.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!post01.iad.highwinds-media.com!fx02.iad.POSTED!not-for-mail Subject: Re: guaranteeing const Newsgroups: comp.lang.c++ References: From: bitrex User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: X-Complaints-To: abuse-at-frugalusenet.com NNTP-Posting-Date: Fri, 18 Nov 2016 20:17:21 UTC Organization: frugalusenet - www.frugalusenet.com Date: Fri, 18 Nov 2016 15:17:21 -0500 X-Received-Body-CRC: 3214056460 X-Received-Bytes: 2246 Xref: panix comp.lang.c++:1125320
On 11/18/2016 03:14 PM, red floyd wrote: > On 11/18/2016 12:06 PM, bitrex wrote: >> On 11/18/2016 01:39 PM, Popping mad wrote: >>> How does one do this without losing the const >>> >>> >>> }; /* constructor */ >>> Node ( const Node &other ){ >>> parent(other.parent()) const; >>> right(other.right() const); >>> left(other.left() const); >>> value(other.value() const); >>> max(other.max()) const; >>> }; /* copy constructor */ >>> ~Node (){}; /* >>> destructor */ >>> >>> >>> msort.h|41 col 25| error: passing ‘const maxpath::Node’ as ‘this’ >>> argument discards qualifiers [-fpermissive] >>> >> >> Probably because your methods "parent", "right", etc. aren't declared >> "const." >> >> What compiler does this compile under? I'm surprised putting "const" >> after a function call like that isn't a syntax error. >> >> If you have to do it this way probably best to create a local non-const >> copy of Node in the copy ctr and pass it in > > I *THINK* he's trying to use an initializer list. I've already told him > his syntax for that is wrong. >
Ah. I would be pretty surprised if the code as it is right there actually compiled...
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: guaranteeing const.eml" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="Re: guaranteeing const.eml"
Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!ottix-news.ottix.net!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.glorb.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!post02.iad.highwinds-media.com!fx02.iad.POSTED!not-for-mail Subject: Re: guaranteeing const Newsgroups: comp.lang.c++ References: From: bitrex User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: X-Complaints-To: abuse-at-frugalusenet.com NNTP-Posting-Date: Fri, 18 Nov 2016 20:23:49 UTC Organization: frugalusenet - www.frugalusenet.com Date: Fri, 18 Nov 2016 15:23:49 -0500 X-Received-Bytes: 2295 X-Received-Body-CRC: 1977504855 Xref: panix comp.lang.c++:1125321
On 11/18/2016 03:14 PM, red floyd wrote: > On 11/18/2016 12:06 PM, bitrex wrote: >> On 11/18/2016 01:39 PM, Popping mad wrote: >>> How does one do this without losing the const >>> >>> >>> }; /* constructor */ >>> Node ( const Node &other ){ >>> parent(other.parent()) const; >>> right(other.right() const); >>> left(other.left() const); >>> value(other.value() const); >>> max(other.max()) const; >>> }; /* copy constructor */ >>> ~Node (){}; /* >>> destructor */ >>> >>> >>> msort.h|41 col 25| error: passing ‘const maxpath::Node’ as ‘this’ >>> argument discards qualifiers [-fpermissive] >>> >> >> Probably because your methods "parent", "right", etc. aren't declared >> "const." >> >> What compiler does this compile under? I'm surprised putting "const" >> after a function call like that isn't a syntax error. >> >> If you have to do it this way probably best to create a local non-const >> copy of Node in the copy ctr and pass it in > > I *THINK* he's trying to use an initializer list. I've already told him > his syntax for that is wrong. >
if what he's shooting for is something like:
Node(const Node& other) : parent(other.parent()), right(other.right()), etc.
then AFAIK the "getters" parent, right etc. need to have "const" after their function declaration or there's gonna be trouble.
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: guaranteeing const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: guaranteeing const.eml"
Path: reader2.panix.com!panix!not-for-mail From: Popping mad Newsgroups: comp.lang.c++ Subject: Re: guaranteeing const Date: Fri, 18 Nov 2016 21:10:50 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: References: NNTP-Posting-Host: www.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reader2.panix.com 1479503450 17183 96.57.23.82 (18 Nov 2016 21:10:50 GMT) X-Complaints-To: abuse-at-panix.com NNTP-Posting-Date: Fri, 18 Nov 2016 21:10:50 +0000 (UTC) User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT b8fc14e git.gnome.org/git/pan2) Xref: panix comp.lang.c++:1125327
On Fri, 18 Nov 2016 12:14:35 -0800, red floyd wrote:
> *THINK* he's trying to use an initializer list. I've already told him > his syntax for that is wrong.
no I am not. Nor was I doing that before. I'm building accessory methods to private data. It happens to be a copy constructor and there is no initializer list. I did wonder if I could, however, condense this into an initializer list, in this case, because I am accessing a parameter and then evaluating its value, which is a class instance, and calling a member of the class which returns a value with is assigned to a member of 'this'.
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: guaranteeing const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: guaranteeing const.eml"
Path: reader2.panix.com!panix!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Alf P. Steinbach" Newsgroups: comp.lang.c++ Subject: Re: guaranteeing const Date: Fri, 18 Nov 2016 23:16:24 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 18 Nov 2016 22:18:28 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="61eb1ecd38d6d5358aa129818f7d8ddf"; logging-data="15244"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX193lAb82d7N1wNm3WGf+lRH" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 In-Reply-To: Cancel-Lock: sha1:GdIf/p++E+EQ1HO5GbwrscIrxtc= Xref: panix comp.lang.c++:1125328
On 18.11.2016 22:10, Popping mad wrote: > On Fri, 18 Nov 2016 12:14:35 -0800, red floyd wrote: > >> *THINK* he's trying to use an initializer list. I've already told him >> his syntax for that is wrong. > > no I am not. Nor was I doing that before. I'm building accessory > methods to private data. It happens to be a copy constructor and there > is no initializer list. I did wonder if I could, however, condense this > into an initializer list, in this case, because I am accessing a > parameter and then evaluating its value, which is a class instance, and > calling a member of the class which returns a value with is assigned to a > member of 'this'. >
You'd better express that as an initializer list.
I.e.
Node( Node const& other ) : parent{ other.parent } , right{ other.right } , left{ other.left } , value{ other.value } , max{ other.max } {}
But this is what the default copy constructor will do, and it will not forget to copy over some item.
So really you should write
Node( Node const& other ) = default;
Or even better, just not declare any copy constructor at all.
Cheers!,
- Alf
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: PNG Coding.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: PNG Coding.eml"
Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail From: legalize+jeeves-at-mail.xmission.com (Richard) Newsgroups: comp.lang.c++ Subject: Re: PNG Coding Date: Fri, 18 Nov 2016 21:07:44 +0000 (UTC) Organization: multi-cellular, biological Sender: legalize+jeeves-at-mail.xmission.com Message-ID: References: Reply-To: (Richard) legalize+jeeves-at-mail.xmission.com Injection-Date: Fri, 18 Nov 2016 21:07:44 +0000 (UTC) Injection-Info: news.xmission.com; posting-host="shell.xmission.com:2607:fa18:0:beef::4"; logging-data="363"; mail-complaints-to="abuse-at-xmission.com" X-Reply-Etiquette: No copy by email, please Mail-Copies-To: never X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: legalize-at-shell.xmission.com (Richard) Xref: panix comp.lang.c++:1125326
[Please do not mail me a copy of your followup]
Popping mad spake the secret code thusly:
>On Wed, 16 Nov 2016 00:15:06 +0100, Christian Gollwitzer wrote: > >> https://github.com/lvandeve/lodepng > >ah, that is good. Thank you.
Interesting, didn't know about that one.
"It's made for C (ISO C90), and has a C++ wrapper with a more convenient interface on top."
Oddly, these days this sort of approach feels backward to me. I'd rather see a library written in C++ with a C wrapper on top. -- "The Direct3D Graphics Pipeline" free book The Terminals Wiki The Computer Graphics Museum Legalize Adulthood! (my blog)
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: PNG Coding.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: PNG Coding.eml"
Path: reader2.panix.com!panix!goblin3!goblin.stu.neva.ru!news.netfront.net!.POSTED.217.30.184.161!not-for-mail From: Juha Nieminen Newsgroups: comp.lang.c++ Subject: Re: PNG Coding Date: Wed, 16 Nov 2016 08:01:40 +0000 (UTC) Organization: Netfront http://www.netfront.net/ Message-ID: References: Injection-Date: Wed, 16 Nov 2016 08:01:40 +0000 (UTC) Injection-Info: adenine.netfront.net; posting-host="217.30.184.161"; logging-data="11635"; mail-complaints-to="news-at-netfront.net" User-Agent: tin/2.2.1-20140504 ("Tober an Righ") (UNIX) (Linux/3.14.79-grbfs-kapsi (x86_64)) Xref: panix comp.lang.c++:1125249
Christian Gollwitzer wrote: > Sean Barret has very impressive (compact) C code to write PNG files in > stb_image_write.h: > > https://github.com/nothings/stb
I appreciate simple projects being as minimal as possible in terms of source files (ie. rather than have a million tiny source files, often requiring configure scripts, makefiles and whatnot, just a few, preferably one or two, source files that Just Work(TM), as they are. Just add them to your project or compile command, and that's it. No fuss, no hassle. I like that.)
However, a header-only implementation using an enormous amount of very large static functions (because C doesn't support inline)? Come on. That goes a bit too far. If you ever include the header file in more than one place, you'll be duplicating all the code in your executable. (I don't think linkers will check if two static functions are completely identical in content and merge them. If some do, great, but AFAIK they usually don't.)
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: PNG Coding.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: PNG Coding.eml"
Path: reader2.panix.com!panix!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Christian Gollwitzer Newsgroups: comp.lang.c++ Subject: Re: PNG Coding Date: Wed, 16 Nov 2016 10:06:47 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 16 Nov 2016 09:06:15 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="7782ea6a012648151f9f6bbf0fa69cf9"; logging-data="24439"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX18qkuZZKIv+gNkr7Zem1Fti6JV6na2ecTM=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 In-Reply-To: Cancel-Lock: sha1:yjBtYMrBis3b0ZjlCyF01kcfGOU= Xref: panix comp.lang.c++:1125253
Am 16.11.16 um 09:01 schrieb Juha Nieminen: > Christian Gollwitzer wrote: >> Sean Barret has very impressive (compact) C code to write PNG files in >> stb_image_write.h: >> >> https://github.com/nothings/stb > > I appreciate simple projects being as minimal as possible in terms of source > files (ie. rather than have a million tiny source files, often requiring > configure scripts, makefiles and whatnot, just a few, preferably one or two, > source files that Just Work(TM), as they are. Just add them to your project > or compile command, and that's it. No fuss, no hassle. I like that.) > > However, a header-only implementation using an enormous amount of very > large static functions (because C doesn't support inline)? Come on. > That goes a bit too far. If you ever include the header file in more > than one place, you'll be duplicating all the code in your executable. > (I don't think linkers will check if two static functions are > completely identical in content and merge them. If some do, great, > but AFAIK they usually don't.) >
Well nothing stops you from removing the static declarations and replacing it by either inline or turn the header file into a "real" library. The license for all the libraries he lists at https://github.com/nothings/single_file_libs is zlib, MIT or public domain, i.e. basically "do whatever you want with it" - and for most parts it is extremely impressive how they fit the functionality into such a small numbero of LOCs with zero dependencies.
Partly the "static" seems to be motivated by the missing "inline" in older C compilers.
You can also always wrap the functionality for you own use in your larger project.
Christian
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: PNG Coding.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: PNG Coding.eml"
Path: reader2.panix.com!panix!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!nzpost2.xs4all.net!not-for-mail Subject: Re: PNG Coding Newsgroups: comp.lang.c++ References: From: Wouter van Ooijen Date: Wed, 16 Nov 2016 18:01:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <582c90d5$0$1849$e4fe514c-at-newszilla.xs4all.nl> NNTP-Posting-Host: 2001:980:a9b1:1:8c7:2877:c06d:a6ef X-Trace: 1479315669 dreader36.news.xs4all.nl 1849 [2001:980:a9b1:1:8c7:2877:c06d:a6ef]:51157 X-Complaints-To: abuse-at-xs4all.nl Xref: panix comp.lang.c++:1125267
Op 16-Nov-16 om 9:01 AM schreef Juha Nieminen: > Christian Gollwitzer wrote: >> Sean Barret has very impressive (compact) C code to write PNG files in >> stb_image_write.h: >> >> https://github.com/nothings/stb > > I appreciate simple projects being as minimal as possible in terms of source > files (ie. rather than have a million tiny source files, often requiring > configure scripts, makefiles and whatnot, just a few, preferably one or two, > source files that Just Work(TM), as they are. Just add them to your project > or compile command, and that's it. No fuss, no hassle. I like that.) > > However, a header-only implementation using an enormous amount of very > large static functions (because C doesn't support inline)? Come on. > That goes a bit too far. If you ever include the header file in more > than one place, you'll be duplicating all the code in your executable.
I don't see why that would lead to executable bloat. Did you try this?
Wouter "Objects? No Thanks!" van Ooijen
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: PNG Coding.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: PNG Coding.eml"
X-Received: by 10.129.128.68 with SMTP id q65mr11580186ywf.135.1479325152060; Wed, 16 Nov 2016 11:39:12 -0800 (PST) X-Received: by 10.157.37.125 with SMTP id j58mr2822559otd.18.1479325151982; Wed, 16 Nov 2016 11:39:11 -0800 (PST) Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!168.235.88.217.MISMATCH!feeder.erje.net!2.us.feeder.erje.net!newspeer1.nac.net!border2.nntp.dca1.giganews.com!nntp.giganews.com!n6no178408qtd.0!news-out.google.com!x12ni929ita.0!nntp.google.com!w132no272943ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.c++ Date: Wed, 16 Nov 2016 11:39:11 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse-at-google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.131.68.184; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK NNTP-Posting-Host: 82.131.68.184 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0086c9c2-1813-4d42-b825-6affc64bed5a-at-googlegroups.com> Subject: Re: PNG Coding From: =?UTF-8?B?w5bDtiBUaWli?= Injection-Date: Wed, 16 Nov 2016 19:39:12 +0000 Content-Type: text/plain; charset=UTF-8 Bytes: 1473 Xref: panix comp.lang.c++:1125273
On Wednesday, 16 November 2016 10:01:49 UTC+2, Juha Nieminen wrote: > > However, a header-only implementation using an enormous amount of very > large static functions (because C doesn't support inline)?
AFAIK 'inline' is in C since C99 and I remember that several C compilers supported it before 1999.
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: PNG Coding.eml" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="Re: PNG Coding.eml"
Path: reader2.panix.com!panix!goblin2!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Alf P. Steinbach" Newsgroups: comp.lang.c++ Subject: Re: PNG Coding Date: Thu, 17 Nov 2016 12:13:21 +0100 Organization: A noiseless patient Spider Message-ID: References: <0086c9c2-1813-4d42-b825-6affc64bed5a-at-googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 17 Nov 2016 11:15:22 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="71c14e1901d7e42210f9ef9f25ea2722"; logging-data="23338"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX18kTbJ+I2cgWGeatjsbwpHL" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 In-Reply-To: <0086c9c2-1813-4d42-b825-6affc64bed5a-at-googlegroups.com> Cancel-Lock: sha1:3QTHI/d05sW/CijfhFeATm5OhzI= Xref: panix comp.lang.c++:1125288
On 16.11.2016 20:39, Öö Tiib wrote: > On Wednesday, 16 November 2016 10:01:49 UTC+2, Juha Nieminen wrote: >> >> However, a header-only implementation using an enormous amount of very >> large static functions (because C doesn't support inline)? > > AFAIK 'inline' is in C since C99 and I remember that several > C compilers supported it before 1999.
The keyword is there but it has slightly different semantics.
Cheers!,
- Alf
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: PNG Coding.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: PNG Coding.eml"
Path: reader2.panix.com!panix!not-for-mail From: Popping mad Newsgroups: comp.lang.c++ Subject: Re: PNG Coding Date: Tue, 15 Nov 2016 20:50:23 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: References: <282a6737-54b1-4f7e-b932-d07b4ff9fd0b-at-googlegroups.com> NNTP-Posting-Host: www.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reader2.panix.com 1479243023 20608 96.57.23.82 (15 Nov 2016 20:50:23 GMT) X-Complaints-To: abuse-at-panix.com NNTP-Posting-Date: Tue, 15 Nov 2016 20:50:23 +0000 (UTC) User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT b8fc14e git.gnome.org/git/pan2) Xref: panix comp.lang.c++:1125220
On Tue, 15 Nov 2016 12:06:12 -0800, Rick C. Hodgin wrote:
> On Windows
/dev/null
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: PNG Coding.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: PNG Coding.eml"
Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!168.235.88.217.MISMATCH!feeder.erje.net!2.us.feeder.erje.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail From: legalize+jeeves-at-mail.xmission.com (Richard) Newsgroups: comp.lang.c++ Subject: Re: PNG Coding Date: Fri, 18 Nov 2016 21:06:27 +0000 (UTC) Organization: multi-cellular, biological Sender: legalize+jeeves-at-mail.xmission.com Message-ID: References: <282a6737-54b1-4f7e-b932-d07b4ff9fd0b-at-googlegroups.com> Reply-To: (Richard) legalize+jeeves-at-mail.xmission.com Injection-Date: Fri, 18 Nov 2016 21:06:27 +0000 (UTC) Injection-Info: news.xmission.com; posting-host="shell.xmission.com:2607:fa18:0:beef::4"; logging-data="363"; mail-complaints-to="abuse-at-xmission.com" X-Reply-Etiquette: No copy by email, please Mail-Copies-To: never X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: legalize-at-shell.xmission.com (Richard) Xref: panix comp.lang.c++:1125325
[Please do not mail me a copy of your followup]
Popping mad spake the secret code thusly:
>On Tue, 15 Nov 2016 12:06:12 -0800, Rick C. Hodgin wrote: > >> On Windows > >/dev/null
Nope, Windows uses NUL:. -- "The Direct3D Graphics Pipeline" free book The Terminals Wiki The Computer Graphics Museum Legalize Adulthood! (my blog)
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: PNG Coding.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: PNG Coding.eml"
Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!168.235.88.217.MISMATCH!feeder.erje.net!2.us.feeder.erje.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail From: legalize+jeeves-at-mail.xmission.com (Richard) Newsgroups: comp.lang.c++ Subject: Re: PNG Coding Date: Fri, 18 Nov 2016 21:05:43 +0000 (UTC) Organization: multi-cellular, biological Sender: legalize+jeeves-at-mail.xmission.com Message-ID: References: Reply-To: (Richard) legalize+jeeves-at-mail.xmission.com Injection-Date: Fri, 18 Nov 2016 21:05:43 +0000 (UTC) Injection-Info: news.xmission.com; posting-host="shell.xmission.com:2607:fa18:0:beef::4"; logging-data="363"; mail-complaints-to="abuse-at-xmission.com" X-Reply-Etiquette: No copy by email, please Mail-Copies-To: never X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: legalize-at-shell.xmission.com (Richard) Xref: panix comp.lang.c++:1125324
[Please do not mail me a copy of your followup]
ruben safir spake the secret code thusly:
>Does anyone know of any sample code for reading PNG files that doesn't >include using libpng.... just straight direct access.
If I were to make a C++ PNG parser/emitter from scratch these days, I might use Boost.Spirit (parser framework that can handle binary blobs quite easily). Another approach might be to overlay a chunk iterator view on top of the raw PNG stream. This would avoid copying of data and might result in something really fast for reading. For writing, its just a stream of chunks that are defined according to the things in them. I don't think there's a way you can avoid at least 1 copying of data into an internal buffer when doing writing. I'm just brainstorming here, so I could be wrong. -- "The Direct3D Graphics Pipeline" free book The Terminals Wiki The Computer Graphics Museum Legalize Adulthood! (my blog)
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="/usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="/usr/include/*_h.eml"
Path: reader2.panix.com!panix!not-for-mail From: Popping mad Newsgroups: comp.lang.c++ Subject: /usr/include/*.h Date: Wed, 16 Nov 2016 03:29:31 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: NNTP-Posting-Host: www.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reader2.panix.com 1479266971 20608 96.57.23.82 (16 Nov 2016 03:29:31 GMT) X-Complaints-To: abuse-at-panix.com NNTP-Posting-Date: Wed, 16 Nov 2016 03:29:31 +0000 (UTC) User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT b8fc14e git.gnome.org/git/pan2) Xref: panix comp.lang.c++:1125239
I am using zlib and it has zlib.h in the /usr/include/ directory on the system. Why can I not use
#include or #include
to include it in my program. It is not being seen.
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: /usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: /usr/include/*_h.eml"
Path: reader2.panix.com!panix!goblin2!goblin1!goblin.stu.neva.ru!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: /usr/include/*.h Date: Wed, 16 Nov 2016 17:25:03 +1300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net maURG4bhO9o3Ng+JaTg0UwS/RjsBLIbNzuAcaLcbWjuMHrq58o Cancel-Lock: sha1:h4uyVJvG1GmFSRNELyalGNATm0E= User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: Xref: panix comp.lang.c++:1125241
On 11/16/16 04:29 PM, Popping mad wrote: > I am using zlib and it has zlib.h in the /usr/include/ directory on the > system. Why can I not use > > #include > or > #include > > to include it in my program. It is not being seen.
Because you forgot the ".h"?
-- Ian
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: /usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: /usr/include/*_h.eml"
Path: reader2.panix.com!panix!not-for-mail From: Popping mad Newsgroups: comp.lang.c++ Subject: Re: /usr/include/*.h Date: Wed, 16 Nov 2016 05:05:39 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: References: NNTP-Posting-Host: www.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reader2.panix.com 1479272739 26297 96.57.23.82 (16 Nov 2016 05:05:39 GMT) X-Complaints-To: abuse-at-panix.com NNTP-Posting-Date: Wed, 16 Nov 2016 05:05:39 +0000 (UTC) User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT b8fc14e git.gnome.org/git/pan2) Xref: panix comp.lang.c++:1125242
On Wed, 16 Nov 2016 17:25:03 +1300, Ian Collins wrote:
>> to include it in my program. It is not being seen. > > Because you forgot the ".h"?
why does it need a .h? Why does it not work like #include
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: /usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: /usr/include/*_h.eml"
Path: reader2.panix.com!panix!goblin1!goblin.stu.neva.ru!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: /usr/include/*.h Date: Wed, 16 Nov 2016 18:51:56 +1300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net kPsTUKJfwPcZ9/H0oYjLtAdWQpbZxRAEdFK5mw74pVqY183YCZ Cancel-Lock: sha1:lxIXhakDzXKWg7JaknwibwR9bbs= User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: Xref: panix comp.lang.c++:1125243
On 11/16/16 06:05 PM, Popping mad wrote: > On Wed, 16 Nov 2016 17:25:03 +1300, Ian Collins wrote: > > >>> to include it in my program. It is not being seen. >> >> Because you forgot the ".h"? > > why does it need a .h? Why does it not work like #include
Because that isn't the name of the file!
-- Ian
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: /usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: /usr/include/*_h.eml"
Path: reader2.panix.com!panix!goblin1!goblin.stu.neva.ru!news.albasani.net!.POSTED!not-for-mail From: Melzzzzz Newsgroups: comp.lang.c++ Subject: Re: /usr/include/*.h Date: Wed, 16 Nov 2016 07:38:42 +0100 Organization: albasani.net Message-ID: <20161116073842.7d9f2952-at-maxa-pc> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net PL68lh1X9f74dveRKN6ImSGlekLpLP9OmaXPZoOXqVdCLfyf8f0pX65+WpqqdRXAm69xm02pCxCyJbVz0qmjsg== NNTP-Posting-Date: Wed, 16 Nov 2016 06:38:42 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="WGvIWFnHP8edB0auZe+SKe86hMYFExWJ0uHYP0qJ2M/7gt8A00Mmlh7XZE5v7IyFyAdu3cKCLXyTdYvJFBfXhd5379tXIppXLV3Gk8TDsk/UpN3ldl3hqDoJN5dPYlSg"; mail-complaints-to="abuse-at-albasani.net" X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-unknown-linux-gnu) Cancel-Lock: sha1:CFPejb2VID2no0muGpg1noklrnI= Xref: panix comp.lang.c++:1125244
On Wed, 16 Nov 2016 18:51:56 +1300 Ian Collins wrote:
> On 11/16/16 06:05 PM, Popping mad wrote: > > On Wed, 16 Nov 2016 17:25:03 +1300, Ian Collins wrote: > > > > > >>> to include it in my program. It is not being seen. > >> > >> Because you forgot the ".h"? > > > > why does it need a .h? Why does it not work like #include > > > > Because that isn't the name of the file! >
He doesn't understand what #include preprocessor directive does...
-- press any key to continue or any other to quit
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: /usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: /usr/include/*_h.eml"
Path: reader2.panix.com!panix!goblin2!goblin.stu.neva.ru!aioe.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Christian Gollwitzer Newsgroups: comp.lang.c++ Subject: Re: /usr/include/*.h Date: Wed, 16 Nov 2016 11:05:53 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 16 Nov 2016 10:05:26 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="75465dfcfee95b463fb478357f65b8d3"; logging-data="6247"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX191H1F+/H3RPi/IR0bDmUHdwcJ6AVvXSjQ=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 In-Reply-To: Cancel-Lock: sha1:IyOGlIuTjO4xaZ92fKUnsNGpqNc= Xref: panix comp.lang.c++:1125254
Am 16.11.16 um 04:29 schrieb Popping mad: > I am using zlib and it has zlib.h in the /usr/include/ directory on the > system. Why can I not use > > #include > or > #include > > to include it in my program. It is not being seen. >
The compiler really only looks for the name that you put into the <>. #include to include #include in std) only works, because the C++ library ships with file called "cstdio", which basically does
namespace std { #include }
There is no magic by which the compiler would derive the .h file from the extensionless name.
Christia
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: /usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: /usr/include/*_h.eml"
Path: reader2.panix.com!panix!not-for-mail From: Popping mad Newsgroups: comp.lang.c++ Subject: Re: /usr/include/*.h Date: Wed, 16 Nov 2016 10:23:36 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: References: NNTP-Posting-Host: www.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reader2.panix.com 1479291816 27290 96.57.23.82 (16 Nov 2016 10:23:36 GMT) X-Complaints-To: abuse-at-panix.com NNTP-Posting-Date: Wed, 16 Nov 2016 10:23:36 +0000 (UTC) User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT b8fc14e git.gnome.org/git/pan2) Xref: panix comp.lang.c++:1125256
On Wed, 16 Nov 2016 11:05:53 +0100, Christian Gollwitzer wrote:
> namespace std { > #include > } > > There is no magic by which the compiler would derive the .h file from > the extensionless name.
that also goes for including the .h which we, by convention do in C but in C++ we drop the .h from the #includes?
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: /usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: /usr/include/*_h.eml"
Path: reader2.panix.com!panix!goblin2!goblin1!goblin.stu.neva.ru!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!buffer2.nntp.ams1.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 16 Nov 2016 05:12:45 -0600 Date: Wed, 16 Nov 2016 13:12:44 +0200 From: Paavo Helde User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.8) Gecko/20151117 FossaMail/25.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.c++ Subject: Re: /usr/include/*.h References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <0PudnTFUMuaworHFnZ2dnUU78K_NnZ2d-at-giganews.com> X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-ACbkiDjns0ibn0ZGT6/0ZpQKWZzJfzU8Ci1WtZbz4R4+bIqsrAc1nCVVffAbfYfSwVCV1RtMLMpOTpg!QrFGo+x5TkFcQAgaQKBYvooBEYWZHXsjes3IfX5JYDnHMZP6MGlEk0tfFhwTf83nw/FySKQyC2Gu X-Complaints-To: abuse-at-giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html 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: 1903 Xref: panix comp.lang.c++:1125258
On 16.11.2016 12:23, Popping mad wrote: > On Wed, 16 Nov 2016 11:05:53 +0100, Christian Gollwitzer wrote: > >> namespace std { >> #include >> } >> >> There is no magic by which the compiler would derive the .h file from >> the extensionless name. > > > that also goes for including the .h which we, by convention do in C but > in C++ we drop the .h from the #includes?
This is not a convention. It's just that C++ standard decided to define some header files with no filename extension. IIRC the idea was that these might not be real disk files at all, so a filename extension is not needed. But in reality typical implementations still have them as actual disk files.
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: /usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: /usr/include/*_h.eml"
Path: reader2.panix.com!panix!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown Newsgroups: comp.lang.c++ Subject: Re: /usr/include/*.h Date: Wed, 16 Nov 2016 17:15:04 +0100 Organization: A noiseless patient Spider Message-ID: References: <0PudnTFUMuaworHFnZ2dnUU78K_NnZ2d-at-giganews.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Date: Wed, 16 Nov 2016 16:14:32 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="07814a151b393e906172b44f077cf14d"; logging-data="17375"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX1/UjMyJIlPJGKdqjTXCp2/x72vXGC3HlYQ=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <0PudnTFUMuaworHFnZ2dnUU78K_NnZ2d-at-giganews.com> Cancel-Lock: sha1:K4Ut+ePCddDN2ocAzHer36tNBM4= Xref: panix comp.lang.c++:1125265
On 16/11/16 12:12, Paavo Helde wrote: > On 16.11.2016 12:23, Popping mad wrote: >> On Wed, 16 Nov 2016 11:05:53 +0100, Christian Gollwitzer wrote: >> >>> namespace std { >>> #include >>> } >>> >>> There is no magic by which the compiler would derive the .h file from >>> the extensionless name. >> >> >> that also goes for including the .h which we, by convention do in C but >> in C++ we drop the .h from the #includes? > > This is not a convention. It's just that C++ standard decided to define > some header files with no filename extension. IIRC the idea was that > these might not be real disk files at all, so a filename extension is > not needed. But in reality typical implementations still have them as > actual disk files. >
It has the convenience of making it easy to distinguish standard library headers and other headers that might be on your compiler's include paths, and means that the C++ standard library can add new headers without worrying about conflicts.
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: /usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: /usr/include/*_h.eml"
Path: reader2.panix.com!panix!news.linkpendium.com!news.linkpendium.com!news.snarked.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail From: legalize+jeeves-at-mail.xmission.com (Richard) Newsgroups: comp.lang.c++ Subject: Re: /usr/include/*.h Date: Thu, 17 Nov 2016 22:58:01 +0000 (UTC) Organization: multi-cellular, biological Sender: legalize+jeeves-at-mail.xmission.com Message-ID: References: Reply-To: (Richard) legalize+jeeves-at-mail.xmission.com Injection-Date: Thu, 17 Nov 2016 22:58:01 +0000 (UTC) Injection-Info: news.xmission.com; posting-host="shell.xmission.com:2607:fa18:0:beef::4"; logging-data="21206"; mail-complaints-to="abuse-at-xmission.com" X-Reply-Etiquette: No copy by email, please Mail-Copies-To: never X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: legalize-at-shell.xmission.com (Richard) Xref: panix comp.lang.c++:1125297
[Please do not mail me a copy of your followup]
Popping mad spake the secret code thusly:
>I am using zlib and it has zlib.h in the /usr/include/ directory on the >system. Why can I not use > >#include
Because the header is named zlib.h. The <> vs. "" just changes the places where the compiler looks for header files. Other than that, you have to specify the entire name of the header file.
>#include
These style of includes, e.g. , are special include file names specified by the ISO C++ standard. zlib is not part of the standard. (One could argue that zlib, not being a standard header file, should not be installed in /usr/include but somewhere else like /opt/include or /usr/local/include or whatever.) -- "The Direct3D Graphics Pipeline" free book The Terminals Wiki The Computer Graphics Museum Legalize Adulthood! (my blog)
--------------4FA1628384734F4ADFC1D36A Content-Type: message/rfc822; name="Re: /usr/include/*_h.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: /usr/include/*_h.eml"
X-Received: by 10.99.108.8 with SMTP id h8mr2253879pgc.50.1479433909693; Thu, 17 Nov 2016 17:51:49 -0800 (PST) X-Received: by 10.157.37.59 with SMTP id k56mr682480otb.3.1479433909647; Thu, 17 Nov 2016 17:51:49 -0800 (PST) Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!168.235.88.217.MISMATCH!feeder.erje.net!2.us.feeder.erje.net!newspeer1.nac.net!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!w132no614498ita.0!news-out.google.com!x12ni2103ita.0!nntp.google.com!w132no614491ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.c++ Date: Thu, 17 Nov 2016 17:51:49 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse-at-google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=174.20.129.81; posting-account=rjB3oAoAAABKfPObATzhh9rhM3ykI7LX NNTP-Posting-Host: 174.20.129.81 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <887c4e1c-514d-4726-942d-f5c59099fa8a-at-googlegroups.com> Subject: Re: /usr/include/*.h From: woodbrian77-at-gmail.com Injection-Date: Fri, 18 Nov 2016 01:51:49 +0000 Content-Type: text/plain; charset=UTF-8 Bytes: 2362 Xref: panix comp.lang.c++:1125303
On Thursday, November 17, 2016 at 4:58:11 PM UTC-6, Richard wrote: > [Please do not mail me a copy of your followup] > > Popping mad spake the secret code > thusly: | |