comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en
comp.lang.c++@googlegroups.com
Today's topics:
* Boost - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/81738d66827a11c8?hl=en
* The Beauties of Islam - 7 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/b79532a504d8f51e?hl=en
* Link object files from VC++ and GCC? - 11 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/d605f2ea0db15eb9?hl=en
* goto label inside of if statement - 6 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/7c222b0d5330287c?hl=en
==============================================================================
TOPIC: Boost
http://groups.google.com/group/comp.lang.c++/t/81738d66827a11c8?hl=en
==============================================================================
== 1 of 2 ==
Date: Tues, Jan 21 2014 5:39 am
From: Martijn Lievaart
On Mon, 20 Jan 2014 20:41:17 +0000, Bob Hammerman wrote:
> J. Clarke wrote:
>
>> What it's good for is avoiding reinventing the wheel. If you have a
>> tested library already available that provides the function that you
>> need with acceptable performance, why rewrite it?
>
> I don't know, but going through reverse engineering other peoples craps
> is more time demanding than going through own crap. Don't you know it,
> where have you been?
Having just debugged a professional well respected open source library, I
can say:
- It's crap
- Debugging it took 1 day, writing this functionality would probably have
taken months, if not a year.
So your statement is not true.
M4
== 2 of 2 ==
Date: Tues, Jan 21 2014 6:59 am
From: Robert Wessel
On Mon, 20 Jan 2014 17:08:48 GMT, scott@slp53.sl.home (Scott Lurndal)
wrote:
>Robert Wessel <robertwessel2@yahoo.com> writes:
>>On Mon, 20 Jan 2014 15:26:52 GMT, scott@slp53.sl.home (Scott Lurndal)
>>wrote:
>>
>>>Nick Baumbach <nich@iwqoc.org> writes:
>>>>Ian Collins oratorically vehemently insists
>>>>
>>>>> On a more up to date machine with gcc:
>>>>>
>>>>> time ./b2 -j 32
>>>>>
>>>>> <stuff>
>>>>>
>>>>> The Boost C++ Libraries were successfully built!
>>>>>
>>>>> real 1m2.319s user 27m57.961s sys 1m49.214s
>>>>
>>>>Wow, -j 32 !! Say no more. Where did you find that 32 since at most I only
>>>>can find 16, as 2 threads per core. Actually thread core, not real core.
>>>>An i7 is still a 4 core, not sure how that threaded core is embedded into
>>>>the hardware.
>>>>
>>>>Please elaborate
>>>
>>>Many larger systems are available. Not too many years ago, I was running
>>>-j384 compiles regularly on a 192-core shared memory system.
>>
>>
>>Although arraigning to build over a cluster would almost certainly be
>>far cheaper. OTOH, I've never looked at the internals of the Boost
>>build system, so I have no idea how hard it would be to get it to do
>>that.
>
>The aforementioned 192-core shared ccNUMA memory system (1TB DRAM) was selling
>for about USD100,000 in 2009. About the same as a simliarly sized cluster
>(16 nodes).
>
>The followon system, which was in design, had 1024 xeon cores instead
>of 192 opteron cores; but the economy stepped in and aborted that plan.
Although a cluster of smaller machines with the same number of cores
would almost certatinly have been a fair bit cheaper. Assuming we're
talking something like PCs where the prices of the low end systems are
substantially less per-MIPS than the big SMPs.
Still, there's no reason not use use all 192 cores for a build if you
have enough RAM and I/O, assuming you have the box already. But if
your application is big builds, a cluster is almost certainly going to
be considerably cheaper since (big) builds are mostly EP.
==============================================================================
TOPIC: The Beauties of Islam
http://groups.google.com/group/comp.lang.c++/t/b79532a504d8f51e?hl=en
==============================================================================
== 1 of 7 ==
Date: Tues, Jan 21 2014 11:13 am
From: Bo Persson
Qu0ll skrev 2014-01-21 11:23:
> wrote in message
> news:c2f415a8-d26c-412e-b137-fdacfa93951c@googlegroups.com...
>
>> The C++ Middleware Writer is based on Judeo/Christian roots.
>> I'm not aware of C++ work based on Islamic roots.
>
> Brian, we both may identify ourselves as Christians but my response to
> that is definitely a big WTF???
>
So Brian admits to being ignorant on islamic software, whatever that is.
Who cares?
== 2 of 7 ==
Date: Tues, Jan 21 2014 2:51 pm
From: woodbrian77@gmail.com
On Tuesday, January 21, 2014 3:27:43 AM UTC-6, Juha Nieminen wrote:
> woodbrian77@gmail.com wrote:
>
> > The C++ Middleware Writer is based on Judeo/Christian roots.
> > I'm not aware of C++ work based on Islamic roots.
>
> I think there's something wrong in your brain.
>
Consider these verses from Psalms 121:
"I will lift up my eyes to the mountains;
From where shall my help come?
My help comes from the L-rd,
Who made heaven and earth.
He will not allow your foot to slip;
He who keeps you will not slumber.
Behold, He who keeps Israel
Will neither slumber nor sleep."
G-d is the original server. He's 100% ready.
I turn to G-d and the Bible for inspiration
and understanding when it comes to providing
quality services. I also ask around here for
ideas. G-d has people all over the world.
Maybe we can agree that C++ is an excellent language
for writing services.
Brian
Ebenezer Enterprises - Ask, and it will be given
to you; seek, and you will find; knock, and it will
be opened to you.
http://webEbenezer.net
== 3 of 7 ==
Date: Tues, Jan 21 2014 3:20 pm
From: woodbrian77@gmail.com
On Tuesday, January 21, 2014 4:51:00 PM UTC-6, woodb...@gmail.com wrote:
>
> Consider these verses from Psalms 121:
>
> "I will lift up my eyes to the mountains;
> From where shall my help come?
> My help comes from the L-rd,
> Who made heaven and earth.
> He will not allow your foot to slip;
>
This is another answer to when Leigh asked me about
the possibility of me being hit by a bus. I replied
with the story about Elijah and Elisha, but here we
have supernatural protection so my foot doesn't slip.
And remember how Elijah was treated. He wasn't hit
by a bus, but was whisked away in a flaming chariot.
== 4 of 7 ==
Date: Wed, Jan 22 2014 3:53 am
From: David Brown
On 22/01/14 00:20, woodbrian77@gmail.com wrote:
> On Tuesday, January 21, 2014 4:51:00 PM UTC-6, woodb...@gmail.com wrote:
>>
>> Consider these verses from Psalms 121:
>>
>> "I will lift up my eyes to the mountains;
>> From where shall my help come?
>> My help comes from the L-rd,
>> Who made heaven and earth.
>> He will not allow your foot to slip;
>>
>
> This is another answer to when Leigh asked me about
> the possibility of me being hit by a bus. I replied
> with the story about Elijah and Elisha, but here we
> have supernatural protection so my foot doesn't slip.
>
> And remember how Elijah was treated. He wasn't hit
> by a bus, but was whisked away in a flaming chariot.
>
Are you really claiming that people should trust your code because it is
"inspired by God", and we can trust your company because you have
supernatural powers and will not die, but be "whisked away", and
presumably continue to provide customer service and support from heaven?
I don't really care what you believe in or not - faith is a personal
matter (except when it affects how you treat other people, of course).
If your faith inspires you to work hard and have confidence in the job
you do, then that's great. But the sort of twaddle you posted here has
no place in a business or profession. A piece of software has no faith,
and a company has no religion - you really have to learn to separate
these from yourself. If you can't do that, switch professions - you'll
make far more money as a TV evangelist.
== 5 of 7 ==
Date: Wed, Jan 22 2014 9:32 am
From: woodbrian77@gmail.com
On Wednesday, January 22, 2014 5:53:24 AM UTC-6, David Brown wrote:
> Are you really claiming that people should trust your code because it is
No. The generated code is available to be read by anyone.
The same is true of a lot of the hand written code.
> "inspired by God", and we can trust your company because you have
> supernatural powers and will not die, but be "whisked away", and
I didn't claim that I won't die. Elijah trained Elisha
to do his job and then Elijah was carried away.
>
>
>
> I don't really care what you believe in or not - faith is a personal
Remember "In G-d we trust".
> and a company has no religion
Ebenezer Enterprises does. Would you agree that the US
has Judeo/Christian roots? I'm thinking of the pilgrims
who sailed across the Atlantic and also thinking of modern
day pilgrims like Sean Hannity
http://www.truthrevolt.org/news/sean-hannity-andrew-cuomo-i-cant-wait-leave-new-york
== 6 of 7 ==
Date: Wed, Jan 22 2014 11:24 am
From: David Brown
On 22/01/14 18:32, woodbrian77@gmail.com wrote:
> On Wednesday, January 22, 2014 5:53:24 AM UTC-6, David Brown wrote:
>
>> Are you really claiming that people should trust your code because it is
>
> No. The generated code is available to be read by anyone.
> The same is true of a lot of the hand written code.
>
Making all your source code available to others is good for trust, of
course.
>> "inspired by God", and we can trust your company because you have
>> supernatural powers and will not die, but be "whisked away", and
>
> I didn't claim that I won't die. Elijah trained Elisha
> to do his job and then Elijah was carried away.
>
So you - on the basis of your beliefs in the OT - you are confident of
training a replacement before getting "whisked away" ?
If you are a one-man company, that's fair enough - as long as you are
clear about this to customers, and have appropriate measures in place
(available documentation, source code, license details, etc.) so that
they know how they can continue with their own work if you get hit by a
bus. But when you tell customers that they don't need to worry because
you've got God on your side, and you are the next Elijah, then any sane
customer will laugh at you.
>>
>>
>>
>> I don't really care what you believe in or not - faith is a personal
>
> Remember "In G-d we trust".
If /you/ want to trust in God, that's fair enough - just don't expect
any customers to trust in /your/ trust.
>
>
>> and a company has no religion
>
> Ebenezer Enterprises does.
A company has no religion. It is not a person, it does not have
beliefs. Your problem is that you fail to understand what a company
/is/, and mix it up with yourself.
A company has a /profile/, and that profile can have ethical or moral
standards (as long as they are legal and non-discriminatory) - but that
is not the same as claiming it has a religion.
> Would you agree that the US
> has Judeo/Christian roots?
A lot of the /people/ who formed the modern USA have Christian roots -
though many do not. The "founding fathers" attempted to make a country
where people could be free to follow whatever religion they wanted,
which was a noble aim and certainly /not/ a Christian idea. If
anything, their inspiration was the Roman Empire with its tradition of
tolerance for many peoples and religions.
> I'm thinking of the pilgrims
> who sailed across the Atlantic and also thinking of modern
> day pilgrims like Sean Hannity
>
> http://www.truthrevolt.org/news/sean-hannity-andrew-cuomo-i-cant-wait-leave-new-york
>
It is well-known that the pilgrim fathers left England because of
"religious persecution" - what is less well-known is that it was the
sect left England because /they/ were not allowed to persecute others.
There was far too much religious freedom (i.e., several different
variants of Christianity were allowed) in England for their tastes, and
they wanted to go somewhere where everyone could be forced to follow
/their/ ideas.
== 7 of 7 ==
Date: Wed, Jan 22 2014 3:14 pm
From: woodbrian77@gmail.com
On Wednesday, January 22, 2014 1:24:41 PM UTC-6, David Brown wrote:
>
> So you - on the basis of your beliefs in the OT - you are confident of
> training a replacement before getting "whisked away" ?
>
I'm not saying I'll be whisked away. Just that Elijah
was whisked away.
> If you are a one-man company, that's fair enough - as long as you are
> clear about this to customers, and have appropriate measures in place
> (available documentation,
It would be nice to have some documentation discussions
here. I acknowledge there's room for improvement on
the documentation and welcome specific ideas on how to
improve it. I've been focusing a lot on the software,
and the docs need work.
> source code, license details, etc.) so that
> they know how they can continue with their own work if you get hit by a
> bus. But when you tell customers that they don't need to worry because
> you've got God on your side, and you are the next Elijah, then any sane
> customer will laugh at you.
>
Ample evidence of the quality is available in terms
of both the generated code and hand written code.
There's also this page
http://webEbenezer.net/comparison.html
.
I'm not the next Elijah. I'm learning from his example.
Habakkuk 2:4
"Behold the proud, his soul is not upright in him; but the
just shall live by his faith."
I can give some help to people to make a decision about
using the C++ Middleware Writer, but as with any other
decision there's some risk involved. For those who are
living by faith in G-d it might be an easier decision
to make than for those aren't.
It doesn't hurt that the company has been here since 1999.
Maybe some will admit that making it to 2014 in better
shape than ever is evidence that G-d has helped us.
>
> > Remember "In G-d we trust".
>
> If /you/ want to trust in God, that's fair enough - just don't expect
> any customers to trust in /your/ trust.
In G-d we trust is the national motto of the United States.
We're upfront about our faith in G-d. We let other people
know the source of our strength.
>
>
> A company has no religion. It is not a person, it does not have
> beliefs. Your problem is that you fail to understand what a company
> /is/, and mix it up with yourself.
>
You fail to acknowledge our rights are from G-d.
Remember our name is Ebenezer - that means "So far G-d
has helped us."
Would you expect anything but the best of work
(interesting, rewarding, etc.) for those who follow G-d?
>
> It is well-known that the pilgrim fathers left England because of
> "religious persecution" - what is less well-known is that it was the
> sect left England because /they/ were not allowed to persecute others.
Your understanding is incorrect. They left in order
to follow G-d according to their conscience. I had
to do the same thing when I started a company. I left
behind those companies with immoral policies. If I
were an employee of IBM, Microsoft, Apple, etc. today,
some of the money I helped them make would be going to
support immoral lifestyles. I said, "Thanks, but no
thanks" to that. If you want to lead a G-dly life, it
will cost you some in terms of income. Unfortunately
what is considered "good" by some is evil from G-d's
perspective.
"Woe to those who call evil good, and good evil;
Who substitute darkness for light and light for darkness;
Who substitute bitter for sweet and sweet for bitter!"
Isaiah 5:20
I see this as a King David against Goliath struggle.
G-d blessed David with the victory over the foul-mouthed
Goliath.
Brian
Ebenezer Enterprises
http://webEbenezer.net
http://www.truthrevolt.org/news/sean-hannity-andrew-cuomo-i-cant-wait-leave-new-york
==============================================================================
TOPIC: Link object files from VC++ and GCC?
http://groups.google.com/group/comp.lang.c++/t/d605f2ea0db15eb9?hl=en
==============================================================================
== 1 of 11 ==
Date: Thurs, Jan 23 2014 9:39 am
From: "Rick C. Hodgin"
Is there a way to link object files between Visual C++ and GCC?
I have some data that I need to encode like this:
char* list[] = {
"one",
"two",
"three",
};
Unfortunately, by default, the list[0], list[1], and list[2] pointers point
to data that's in read-only memory. Any attempt to do something like
memcpy(list[0], "eno", 3) fails with "Access Violation" on Windows.
So, I discovered this syntax in GCC which creates the elements in read-write
memory, allowing memcpy(list[0], "eno", 3) to work properly:
char* list[] = {
(char []) { "one" },
(char []) { "two" },
(char []) { "three" },
};
I need the data pointed to by those list elements to be read-write in my
application. I can use this compound literal syntax in GCC to create
them in read-write memory, and it works in GCC. However, Visual C++
does not support this compound literal syntax and generates about 5
errors per line when I attempt it. :-)
I was wondering if there's a way to link in that one file, which will
contain nothing more than a list like this sample, but with about 100
separate elements in it representing a source code file I need to
modify somewhat at use (replacing placeholders like "[9999]" with the
actual runtime observed values, such as "[ 1]" and so on), to my
Visual C++ generated code in Visual Studio 2008?
I'm looking for something like this:
gcc -c my_list.c
cl /c my_prog.cpp
link my_list.o my_prog.obj my_prog.exe
Thank you in advance.
Best regards,
Rick C. Hodgin
== 2 of 11 ==
Date: Thurs, Jan 23 2014 9:40 am
From: "Rick C. Hodgin"
In the alternative, does anyone know of a version of a Windows-based C/C++
compiler that will honor the compound literal syntax, which will link in
with the correct object format?
Best regards,
Rick C. Hodgin
== 3 of 11 ==
Date: Thurs, Jan 23 2014 10:14 am
From: "Alf P. Steinbach"
On 23.01.2014 18:39, Rick C. Hodgin wrote:
> Is there a way to link object files between Visual C++ and GCC?
>
> I have some data that I need to encode like this:
> char* list[] = {
> "one",
> "two",
> "three",
> };
>
> Unfortunately, by default, the list[0], list[1], and list[2] pointers point
> to data that's in read-only memory. Any attempt to do something like
> memcpy(list[0], "eno", 3) fails with "Access Violation" on Windows.
>
> So, I discovered this syntax in GCC which creates the elements in read-write
> memory, allowing memcpy(list[0], "eno", 3) to work properly:
> char* list[] = {
> (char []) { "one" },
> (char []) { "two" },
> (char []) { "three" },
> };
>
> I need the data pointed to by those list elements to be read-write in my
> application. I can use this compound literal syntax in GCC to create
> them in read-write memory, and it works in GCC. However, Visual C++
> does not support this compound literal syntax and generates about 5
> errors per line when I attempt it. :-)
>
> I was wondering if there's a way to link in that one file, which will
> contain nothing more than a list like this sample, but with about 100
> separate elements in it representing a source code file I need to
> modify somewhat at use (replacing placeholders like "[9999]" with the
> actual runtime observed values, such as "[ 1]" and so on), to my
> Visual C++ generated code in Visual Studio 2008?
>
> I'm looking for something like this:
> gcc -c my_list.c
> cl /c my_prog.cpp
> link my_list.o my_prog.obj my_prog.exe
>
Should work, if you get the name mangling compatible. Since both
compilers use COFF format. But you're barking up the wrong tree: it
doesn't make sense to do this.
First of all you don't need the data to be read/write.
Secondly, if you did need the data to be read/write (which you don't)
it's trivial to specify that:
char item_0[] = "one";
and so on, as long item_0 is static.
Cheers & hth.,
- Alf
== 4 of 11 ==
Date: Thurs, Jan 23 2014 11:20 am
From: Victor Bazarov
On 1/23/2014 12:40 PM, Rick C. Hodgin wrote:
> In the alternative, does anyone know of a version of a Windows-based C/C++
> compiler that will honor the compound literal syntax, which will link in
> with the correct object format?
Why not just use implementation-specific feature in VC++ to place your
data in the read-write memory and go for const-casting it before trying
to change? That's easier than linking GCC obj files with VC++ ones.
You also could simply declare your 'list' as an array of arrays instead
of the array of pointers. That would just as well allow you to edit
those elements:
char list[][10] = { "one", "two", "three" };
It's been a while I used straight chars, though, take it with a grain of
salt. Alternatively, use 'std::string':
std::string list[] = { "one", "two", "three" };
...
list[0]= "eno";
and forget about memcpy...
V
--
I do not respond to top-posted replies, please don't ask
== 5 of 11 ==
Date: Thurs, Jan 23 2014 11:33 am
From: Robert Wessel
On Thu, 23 Jan 2014 09:40:27 -0800 (PST), "Rick C. Hodgin"
<rick.c.hodgin@gmail.com> wrote:
>In the alternative, does anyone know of a version of a Windows-based C/C++
>compiler that will honor the compound literal syntax, which will link in
>with the correct object format?
ICC will probably do it, it implements most GCC extensions.
== 6 of 11 ==
Date: Thurs, Jan 23 2014 11:43 am
From: scott@slp53.sl.home (Scott Lurndal)
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> writes:
>On 23.01.2014 18:39, Rick C. Hodgin wrote:
>> Is there a way to link object files between Visual C++ and GCC?
>>
>> I have some data that I need to encode like this:
>> char* list[] = {
>> "one",
>> "two",
>> "three",
>> };
>>
>> Unfortunately, by default, the list[0], list[1], and list[2] pointers point
>> to data that's in read-only memory. Any attempt to do something like
>> memcpy(list[0], "eno", 3) fails with "Access Violation" on Windows.
>>
>> So, I discovered this syntax in GCC which creates the elements in read-write
>> memory, allowing memcpy(list[0], "eno", 3) to work properly:
>> char* list[] = {
>> (char []) { "one" },
>> (char []) { "two" },
>> (char []) { "three" },
>> };
>>
>> I need the data pointed to by those list elements to be read-write in my
>> application. I can use this compound literal syntax in GCC to create
>> them in read-write memory, and it works in GCC. However, Visual C++
>> does not support this compound literal syntax and generates about 5
>> errors per line when I attempt it. :-)
>>
>> I was wondering if there's a way to link in that one file, which will
>> contain nothing more than a list like this sample, but with about 100
>> separate elements in it representing a source code file I need to
>> modify somewhat at use (replacing placeholders like "[9999]" with the
>> actual runtime observed values, such as "[ 1]" and so on), to my
>> Visual C++ generated code in Visual Studio 2008?
>>
>> I'm looking for something like this:
>> gcc -c my_list.c
>> cl /c my_prog.cpp
>> link my_list.o my_prog.obj my_prog.exe
>>
>
>Should work, if you get the name mangling compatible. Since both
>compilers use COFF format. But you're barking up the wrong tree: it
>doesn't make sense to do this.
gcc hasn't used COFF format for over a decade or more. ELF has been
the standard on unix and unix-like operating systems since 1990.
You are correct, however, in that it doesn't make any sense to do this.
== 7 of 11 ==
Date: Thurs, Jan 23 2014 11:52 am
From: scott@slp53.sl.home (Scott Lurndal)
scott@slp53.sl.home (Scott Lurndal) writes:
>"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> writes:
>>Should work, if you get the name mangling compatible. Since both
>>compilers use COFF format. But you're barking up the wrong tree: it
>>doesn't make sense to do this.
>
>gcc hasn't used COFF format for over a decade or more. ELF has been
>the standard on unix and unix-like operating systems since 1990.
My Bad - missed the windows references. Not surprising that they're
25 years out of date :-)
== 8 of 11 ==
Date: Thurs, Jan 23 2014 11:58 am
From: "Rick C. Hodgin"
I have a data portion that is a source file that changes from time to time.
It is about 100 lines long. I include that in the source file to be written
out to the output file. It contains portions like this (greatly simplified
for this example):
char* sourceCode[] = {
"if (thisThing.someOtherThing[9999].function())\r\n",
"{\r\n",
" // Do something\r\n",
"} else {\r\n",
" // Do something else\r\n",
"}\r\n"
};
The actual code is in another language and contains several references to
the "[9999]" portion, which I swap out with an iterative value at runtime.
I currently have 812 instances where this is generated and they increment
accordingly. I have a "macro" routine that searches for [ and ] on the
same line with 4 characters between them, and then updates the value within
using something like sprintf(line[n] + location, "%4u", iterativeValue);.
I have considered doing it like this:
char sourceCode[] =
"if (thisThing.someOtherThing[9999].function())\r\n"
"{\r\n"
" // Do something\r\n"
"} else {\r\n"
" // Do something else\r\n"
"}\r\n";
And having a read-write value that way, but there are some goals of future
expansion where there will be more than one replacement done within. So,
I wanted it line-by-line so I could tag on a prefix on each line indicating
the type of value that should be there, and so on.
The workaround I'm using right now is to add something like this at startup:
char* sourceCode[] = {
"if (thisThing.someOtherThing[9999].function())\r\n",
"{\r\n",
" // Do something\r\n",
"} else {\r\n",
" // Do something else\r\n",
"}\r\n",
null
};
for (int i = 0; list[i]; i++)
list[0] = strdup(list[0]);
In that way, everything is read-write. But, with the compound literal
syntax I don't need to do anything at startup, and can simply create
read-write variables at compile-time, which are then directly usable
at runtime. I made a macro to do this:
#define RW(x) (char []) { x }
char* sourceCode[] = {
RW("if (thisThing.someOtherThing[9999].function())\r\n"),
RW("{\r\n"),
RW(" // Do something\r\n"),
RW("} else {\r\n"),
RW(" // Do something else\r\n"),
RW("}\r\n"),
null
};
Now the compiler does all the work for me, and I just use the read-write
strings auto-populated for me at startup.
No, I don't need to do it this way. There are a few design decisions
which have factored in to me doing it this way.
Best regards,
Rick C. Hodgin
== 9 of 11 ==
Date: Thurs, Jan 23 2014 12:06 pm
From: "Rick C. Hodgin"
Should be:
for (int i = 0; list[i]; i++)
list[i] = strdup(list[i]);
Best regards,
Rick C. Hodgin
== 10 of 11 ==
Date: Thurs, Jan 23 2014 12:33 pm
From: "Rick C. Hodgin"
COFF output in GCC was the key. I was able to get it working.
Here's are the steps for a sample build:
(1) Install MinGW on Windows with GCC and bases.
(2) Create the two source files below.
(3) Launch a command prompt that has the path for visual studio tools.
(4) Execute these steps:
(a) C:\>PATH=%PATH%;c:\mingw\bin\
(b) C:\>g++ -c -gcoff list.cpp -o list.obj
(c) C:\>cl /c main.cpp
(d) C:\>link main.obj list.obj /OUT:main.exe
(e) C:\>main
!ne
!wo
!three
(f) C:\>_
=========list.cpp========
#define RW(x) (char []) { x }
extern "C"
{
char* list[] =
{
RW("one"),
RW("two"),
RW("three")
};
}
===========END===========
=========main.cpp========
#include <stdlib.h>
#include <stdio.h>
extern "C"
{
extern char* list[];
}
int main(int argc, char* argv[])
{
for (int i = 0; list[i]; i++)
{
list[i][0] = '!'; // Prove it's read-write
puts(list[i]); // Show it
}
}
===========END===========
G++ and CL working hand-in-hand. :-)
Best regards,
Rick C. Hodgin
== 11 of 11 ==
Date: Thurs, Jan 23 2014 12:45 pm
From: "Rick C. Hodgin"
On Thursday, January 23, 2014 2:20:49 PM UTC-5, Victor Bazarov wrote:
> Why not just use implementation-specific feature in VC++ to place your
> data in the read-write memory and go for const-casting it before trying
> to change? That's easier than linking GCC obj files with VC++ ones.
Such as?
> You also could simply declare your 'list' as an array of arrays instead
> of the array of pointers. That would just as well allow you to edit
> those elements:
> char list[][10] = { "one", "two", "three" };
This option was discussed, but it is wasteful. As I say the actual
implementation is about 100 lines of source code, some of which are 80+
characters long, most of which are 15 characters long.
> It's been a while I used straight chars, though, take it with a grain of
> salt. Alternatively, use 'std::string':
> std::string list[] = { "one", "two", "three" };
> ...
> list[0]= "eno";
> and forget about memcpy...
I am currently working on developing my own C-like language that has some
elements of C and some of C++, called RDC (Rapid Development Compiler).
I will not support std::string in that language, along with many other C++
features, so I am not using them for that reason. I hope someday to migrate
all of my code to my own compiler.
Best regards,
Rick C. Hodgin
==============================================================================
TOPIC: goto label inside of if statement
http://groups.google.com/group/comp.lang.c++/t/7c222b0d5330287c?hl=en
==============================================================================
== 1 of 6 ==
Date: Thurs, Jan 23 2014 11:32 am
From: W Karas
I was surprised to find that this code:
struct A { A(); ~A(); };
void bar();
void foo(bool f)
{
if (0)
{
LAB: ;
}
else
{
A a;
if (f) goto LAB;
bar();
}
}
will compile without warnings using GCC 4.7.3, even with -Wall and -Wextra .
The point, in case you were wondering, would be a macro-based "named block" pseudo-construct, where the block could be exited from any depth of block nesting, for example:
#define BLOCK(NAME) if (0) { NAME: ; } else
#define EXITBLOCK(NAME) goto NAME;
struct A { A(); ~A(); };
void bar();
void foo(bool f)
{
BLOCK(XYZ)
{
A a;
if (f) EXITBLOCK(XYZ)
bar();
}
}
== 2 of 6 ==
Date: Thurs, Jan 23 2014 11:55 am
From: Victor Bazarov
On 1/23/2014 2:32 PM, W Karas wrote:
> I was surprised to find that this code:
>
> struct A { A(); ~A(); };
>
> void bar();
>
> void foo(bool f)
> {
> if (0)
> {
> LAB: ;
> }
> else
> {
> A a;
>
> if (f) goto LAB;
>
> bar();
> }
> }
>
> will compile without warnings using GCC 4.7.3, even with -Wall and -Wextra .
>
> The point, in case you were wondering, would be a macro-based "named block" pseudo-construct, where the block could be exited from any depth of block nesting, for example:
>
> #define BLOCK(NAME) if (0) { NAME: ; } else
> #define EXITBLOCK(NAME) goto NAME;
>
> struct A { A(); ~A(); };
>
> void bar();
>
> void foo(bool f)
> {
> BLOCK(XYZ)
> {
> A a;
>
> if (f) EXITBLOCK(XYZ)
>
> bar();
> }
> }
>
And it actually skips the 'else' part when jumping into the 'if'
section, yes? And how well do optimizers handle it?
V
--
I do not respond to top-posted replies, please don't ask
== 3 of 6 ==
Date: Thurs, Jan 23 2014 12:08 pm
From: W Karas
On Thursday, January 23, 2014 2:55:35 PM UTC-5, Victor Bazarov wrote:
> On 1/23/2014 2:32 PM, W Karas wrote:
>
> > I was surprised to find that this code:
>
> >
>
> > struct A { A(); ~A(); };
>
> >
>
> > void bar();
>
> >
>
> > void foo(bool f)
>
> > {
>
> > if (0)
>
> > {
>
> > LAB: ;
>
> > }
>
> > else
>
> > {
>
> > A a;
>
> >
>
> > if (f) goto LAB;
>
> >
>
> > bar();
>
> > }
>
> > }
>
> >
>
> > will compile without warnings using GCC 4.7.3, even with -Wall and -Wextra .
>
> >
>
> > The point, in case you were wondering, would be a macro-based "named block" pseudo-construct, where the block could be exited from any depth of block nesting, for example:
>
> >
>
> > #define BLOCK(NAME) if (0) { NAME: ; } else
>
> > #define EXITBLOCK(NAME) goto NAME;
>
> >
>
> > struct A { A(); ~A(); };
>
> >
>
> > void bar();
>
> >
>
> > void foo(bool f)
>
> > {
>
> > BLOCK(XYZ)
>
> > {
>
> > A a;
>
> >
>
> > if (f) EXITBLOCK(XYZ)
>
> >
>
> > bar();
>
> > }
>
> > }
>
> >
>
>
>
> And it actually skips the 'else' part when jumping into the 'if'
>
> section, yes? And how well do optimizers handle it?
It runs correctly, at least this trivial example does:
#include <cstdio>
struct A {
A() { std::printf("A\n"); }
~A() { std::printf("~A\n"); }
};
void bar() { std::printf("BAR\n"); }
void foo(bool f)
{
if (0)
{
LAB: ;
}
else
{
A a;
if (f) goto LAB;
bar();
}
}
int main(void)
{
foo(true);
std::printf("---\n");
foo(false);
return(0);
}
output:
A
~A
---
A
BAR
~A
Works with GCC -O3 option
== 4 of 6 ==
Date: Thurs, Jan 23 2014 12:08 pm
From: drew@furrfu.invalid (Drew Lawson)
In article <ad5b0a02-29ab-4222-bdde-e0d3ead47ab5@googlegroups.com>
W Karas <wkaras@yahoo.com> writes:
>
>The point, in case you were wondering, would be a macro-based "named block" pseudo-construct, where the
>block could be exited from any depth of block nesting, for example:
>
>#define BLOCK(NAME) if (0) { NAME: ; } else
>#define EXITBLOCK(NAME) goto NAME;
>
>struct A { A(); ~A(); };
>
>void bar();
>
>void foo(bool f)
> {
> BLOCK(XYZ)
> {
> A a;
>
> if (f) EXITBLOCK(XYZ)
>
> bar();
> }
> }
I can't give a cite, but I was always under the impression that a
goto thta crosses block boundaries (into or out of a block) is
undefined behaviour.
--
Drew Lawson What would Brian Boitano do?
== 5 of 6 ==
Date: Thurs, Jan 23 2014 12:38 pm
From: Robert Wessel
On Thu, 23 Jan 2014 20:08:23 +0000 (UTC), drew@furrfu.invalid (Drew
Lawson) wrote:
>In article <ad5b0a02-29ab-4222-bdde-e0d3ead47ab5@googlegroups.com>
> W Karas <wkaras@yahoo.com> writes:
>>
>>The point, in case you were wondering, would be a macro-based "named block" pseudo-construct, where the
>>block could be exited from any depth of block nesting, for example:
>>
>>#define BLOCK(NAME) if (0) { NAME: ; } else
>>#define EXITBLOCK(NAME) goto NAME;
>>
>>struct A { A(); ~A(); };
>>
>>void bar();
>>
>>void foo(bool f)
>> {
>> BLOCK(XYZ)
>> {
>> A a;
>>
>> if (f) EXITBLOCK(XYZ)
>>
>> bar();
>> }
>> }
>
>
>I can't give a cite, but I was always under the impression that a
>goto thta crosses block boundaries (into or out of a block) is
>undefined behaviour.
It arguably should be a error to jump to a different leg in the block
hierarchy, or into a more inner block, but just jumping "out" a layer
or N would just be normal practice (for example, breaking out of a
couple layers of loop).
IOW:
{
{
a:
{
b:
{
c:
{
d:
}
goto X;
e:
}
f:
{
b:, c:, e: and f: would be valid targets, but a: and d: not.
}
OTOH, C doesn't make any of those restrictions.
== 6 of 6 ==
Date: Thurs, Jan 23 2014 12:45 pm
From: Elcaro Nosille
Drew Lawson wrote:
> I can't give a cite, but I was always under the impression that
> a goto thta crosses block boundaries (into or out of a block) is
> undefined behaviour.
It's not possible when you go to a label that is after the
initialization of an object.
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en
To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment