Sunday, January 26, 2014

comp.lang.c++ - 26 new messages in 3 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* goto label inside of if statement - 12 messages, 8 authors
http://groups.google.com/group/comp.lang.c++/t/7c222b0d5330287c?hl=en
* Link object files from VC++ and GCC? - 12 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/d605f2ea0db15eb9?hl=en
* Boost - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/81738d66827a11c8?hl=en

==============================================================================
TOPIC: goto label inside of if statement
http://groups.google.com/group/comp.lang.c++/t/7c222b0d5330287c?hl=en
==============================================================================

== 1 of 12 ==
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?




== 2 of 12 ==
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.




== 3 of 12 ==
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.





== 4 of 12 ==
Date: Thurs, Jan 23 2014 1:09 pm
From: W Karas


On Thursday, January 23, 2014 3:45:44 PM UTC-5, Elcaro Nosille wrote:
> 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.

That seems an accurate summary of what the Standard says, from 6.7-3:

It is possible to transfer into a block, but not in a way that bypasses declarations with initialization. A program that jumps(*) from a point where a variable with automatic storage duration is not in scope to a point where it is in scope is ill-formed unless the variable has scalar type, class type with a trivial default constructor and a trivial destructor, a cv-qualified version of one of these types, or an array of one of the preceding types and is declared without an initializer (8.5). [ Example:
void f() {
// ...
goto lx; // ill-formed: jump into scope of a
ly:
X a = 1;
// ...
lx:
goto ly; // OK, jump implies destructor
// call for a followed by construction
// again immediately following label ly
}

* The transfer from the condition of a switch statement to a case label is considered a jump in this respect.

(This is a quote from the draft Standard dated 2013-10-13.)




== 5 of 12 ==
Date: Thurs, Jan 23 2014 1:11 pm
From: W Karas


On Thursday, January 23, 2014 2:32:13 PM UTC-5, 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();
>
> }
>
> }

I added the -pendantic switch, still no warnings.




== 6 of 12 ==
Date: Thurs, Jan 23 2014 2:56 pm
From: Mr Flibble


On 23/01/2014 19:32, W Karas wrote:

> #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();
> }
> }

That code is awful mate, don't do it.

/Flibble





== 7 of 12 ==
Date: Thurs, Jan 23 2014 3:54 pm
From: W Karas


On Thursday, January 23, 2014 5:56:34 PM UTC-5, Mr Flibble wrote:
> On 23/01/2014 19:32, W Karas wrote:
>
>
>
> > #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();
>
> > }
>
> > }
>
>
>
> That code is awful mate, don't do it.
>
>
>
> /Flibble

What't the better alternative when you have to break out of an outer block, or a block that's not the body of a switch or loop?




== 8 of 12 ==
Date: Thurs, Jan 23 2014 4:08 pm
From: Mr Flibble


On 23/01/2014 23:54, W Karas wrote:
> On Thursday, January 23, 2014 5:56:34 PM UTC-5, Mr Flibble wrote:
>> On 23/01/2014 19:32, W Karas wrote:
>>
>>
>>
>>> #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();
>>
>>> }
>>
>>> }
>>
>>
>>
>> That code is awful mate, don't do it.
>>
>>
>>
>> /Flibble
>
> What't the better alternative when you have to break out of an outer block, or a block that's not the body of a switch or loop?

It is awful because breaking out of a bock that's not the body of a
switch or loop is awful.

/Flibble





== 9 of 12 ==
Date: Thurs, Jan 23 2014 4:09 pm
From: Mr Flibble


On 24/01/2014 00:08, Mr Flibble wrote:
> On 23/01/2014 23:54, W Karas wrote:
>> On Thursday, January 23, 2014 5:56:34 PM UTC-5, Mr Flibble wrote:
>>> On 23/01/2014 19:32, W Karas wrote:
>>>
>>>
>>>
>>>> #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();
>>>
>>>> }
>>>
>>>> }
>>>
>>>
>>>
>>> That code is awful mate, don't do it.
>>>
>>>
>>>
>>> /Flibble
>>
>> What't the better alternative when you have to break out of an outer
>> block, or a block that's not the body of a switch or loop?
>
> It is awful because breaking out of a bock that's not the body of a
> switch or loop is awful.

Hiding goto inside a macro does not make goto any less bad. The only
acceptable use of goto is to break out of a deeply nested loop.

/Flibble





== 10 of 12 ==
Date: Thurs, Jan 23 2014 7:16 pm
From: Victor Bazarov


On 1/23/2014 6:54 PM, W Karas wrote:
>[..]
> What't the better alternative when you have to break out of an outer
block, or a block that's not the body of a switch or loop?

Throw an exception.

Breaking out of nested loops is the only situation in which it's
reasonable, I think. The easiest thing in that case, however, is to
wrap your loops in a function and 'return' from it. I know, I know, not
the best solution, either, especially considering that you'd need the
context pass in somehow. Perhaps wrap it in a lambda that captures
everything...

V
--
I do not respond to top-posted replies, please don't ask




== 11 of 12 ==
Date: Fri, Jan 24 2014 12:00 am
From: David Brown


On 23/01/14 20:32, 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();
> }
> }
>


Such unstructured mixes of control flow /are/ possible in C, and can
sometimes be a good idea. But you need to be /very/ careful about what
you are doing - usually it is not worth the cost in terms of the
confusion you cause yourself and other readers. It is often better to
just duplicate some code sections (either copy-and-paste duplication, or
extracting a function which you might then make "static inline"). If it
is possible to combine the sections safely, then let the compiler's
optimiser do it for you.

You might be interested in looking up "protothreads" for a way of mixing
switches, labels, and other structures in order to make a simple
cooperative multi-threading system. I haven't used it myself, but I
believe it is all legal in C.






== 12 of 12 ==
Date: Fri, Jan 24 2014 1:04 am
From: Stuart


On 04/23/14, 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 .

[snip]

I remember that I read a lot of discussions about whether
http://en.wikipedia.org/wiki/Duff's_device is legal C++ or undefined
behaviour. Even though this is a bit different from your case, maybe
those discussion contain some valuable information for you, too.

Regards,
Stuart






==============================================================================
TOPIC: Link object files from VC++ and GCC?
http://groups.google.com/group/comp.lang.c++/t/d605f2ea0db15eb9?hl=en
==============================================================================

== 1 of 12 ==
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




== 2 of 12 ==
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




== 3 of 12 ==
Date: Thurs, Jan 23 2014 2:13 pm
From: David Brown


On 23/01/14 18:40, 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?
>

Yes, gcc runs fine on Windows. Download mingw. I believe it is even
possible to get VS to work with such "alien" compilers, but I don't know
how well it will handle modern C syntax highlighting.






== 4 of 12 ==
Date: Fri, Jan 24 2014 12:34 am
From: "Hans-Peter"



"Rick C. Hodgin" wrote in message
news:0f20b7fc-b6b1-46d6-a733-bff0636cb5a7@googlegroups.com...
>
> 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.

You can force that the list will be in the data segment by using #pragma
data_seg() but this will only move the pointer array in to the data segment.
Changing the strings to fixed size will do the job:

#pragma data_seg()
char list[3][6] = {
{ "one" },
{ "two" },
{ "three"}
};

BTW the compiler will throw an error if you set the array dimensions too
small.

Best regards
Hans-Peter





== 5 of 12 ==
Date: Fri, Jan 24 2014 5:49 am
From: "Rick C. Hodgin"


On Friday, January 24, 2014 3:34:26 AM UTC-5, Hans-Peter wrote:
> "Rick C. Hodgin" wrote in message
> > 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.
>
> You can force that the list will be in the data segment by using #pragma
> data_seg() but this will only move the pointer array in to the data segment.
> Changing the strings to fixed size will do the job:
> #pragma data_seg()
> char list[3][6] = {
> { "one" },
> { "two" },
> { "three"}
> };
>
> BTW the compiler will throw an error if you set the array dimensions too
> small.

Hans-Peter, thank you for your response. I had considered using the [6]
add-on. The actual implementation is about 100 lines, which are source
code lines from another computer language. The lines vary in length from
a few characters up to over 80, the average probably being 15. I had
decided against using the [85] so as to not waste memory.

I like this new solution, as it not only allows me to do my simple list[]
thing, but also to use GCC and VC++ together.

FWIW, I'm not using the GCC/VC++ solution for my project. The original
solution I found is working just fine. :-) This whole thing has been
more of a mental exercise to try to find an alternate course.

Best regards,
Rick C. Hodgin




== 6 of 12 ==
Date: Fri, Jan 24 2014 6:31 am
From: Victor Bazarov


On 1/24/2014 8:49 AM, Rick C. Hodgin wrote:
> [..] The actual implementation is about 100 lines, which are source
> code lines from another computer language. The lines vary in length from
> a few characters up to over 80, the average probably being 15. I had
> decided against using the [85] so as to not waste memory.
> [..]

Just curious, in what world a few hundred bytes is a waste of memory
worthy of consideration? Are you targetting an embedded system or a
legacy computer with 640K memory (last century technology)? Don't get
me wrong, please, it's just that I have often enough seen real
(significant) time wasted on finding a solution to save a few
microseconds or a few [hundred] bytes, that usually in the end cannot be
accounted for. I can understand when students do that in the course of
their studies, but I don't understand the need for it when creating a
product for others to consume.

V
--
I do not respond to top-posted replies, please don't ask




== 7 of 12 ==
Date: Fri, Jan 24 2014 7:53 am
From: "Rick C. Hodgin"


On Friday, January 24, 2014 9:31:40 AM UTC-5, Victor Bazarov wrote:
> On 1/24/2014 8:49 AM, Rick C. Hodgin wrote:
> > [..] The actual implementation is about 100 lines, which are source
> > code lines from another computer language. The lines vary in length from
> > a few characters up to over 80, the average probably being 15. I had
> > decided against using the [85] so as to not waste memory.
> > [..]
>
> Just curious, in what world a few hundred bytes is a waste of memory
> worthy of consideration? Are you targetting an embedded system or a
> legacy computer with 640K memory (last century technology)? Don't get
> me wrong, please, it's just that I have often enough seen real
> (significant) time wasted on finding a solution to save a few
> microseconds or a few [hundred] bytes, that usually in the end cannot be
> accounted for. I can understand when students do that in the course of
> their studies, but I don't understand the need for it when creating a
> product for others to consume.

I'm getting a lot of flack over this from many people on many lists. It's
like ... if I don't do it the way everybody else does then I'm the one who's
wrong. And because I look toward things which are important to me, and
because I choose to not waste memory where it doesn't need to be wasted,
while also simplifying the source code implementation of this task, that
it is somehow a bad choice.

FWIW, I had a working solution after getting the first access violation error
in the Visual Studio debugger and realizing why I got it. It took me a few
seconds to realize what was happening, even though it was unexpected. But,
the whole issue was one of those things I wanted to better understand. It
seemed (and still seems) a very silly imposition, that string literals
created in that way (as data pointed to in a read-write array) should always
be read-only unless they are explicitly cast through such a clunky syntax as
compound literals, a feature that not all C compilers even support.

It was a mental exercise as much as anything else, a pursuit of a question,
to satiate curiosity. I wound up not using the solution, but just
discovering and testing it out. I learned many things in the process, not
the least of which was how to integrate GCC and Visual C++ together in
harmony. That alone was worth all the time I spent on it.

> I do not respond to top-posted replies, please don't ask

Just curious, in what world would you deny giving help to someone in need
simply because they top-posted? I had someone in 2011 or 2012 on the
Trisquel mailing list tell me that I was a top poster and that he
wasn't going to help me. I didn't even know what he was talking about
and had to ask what that phrase "top poster" meant. When I found out
I was floored that such a ridiculous barrier exists between the
help-seekers, and the knowledge-holders on a forum like this.

It really taught me something ... a concept that is so amazingly important
to only a select few, those who desire to divide people into groups of
"them" (top posters) and "us" (the sensible lot). Seeing your tagline here
in this forum I was again floored. I almost wrote something to you about
it yesterday.

Just so you know ... there's a better way, Victor. It's called "love".
Tear down the barriers and come out and help people in love. And if you
want to learn the fulness of love ... He is the man, named Jesus, who is
the Christ, the only Savior of mankind.

Best regards,
Rick C. Hodgin




== 8 of 12 ==
Date: Fri, Jan 24 2014 8:44 am
From: Victor Bazarov


On 1/24/2014 10:53 AM, Rick C. Hodgin wrote:
> On Friday, January 24, 2014 9:31:40 AM UTC-5, Victor Bazarov wrote:
>> On 1/24/2014 8:49 AM, Rick C. Hodgin wrote:
>>> [..] The actual implementation is about 100 lines, which are source
>>> code lines from another computer language. The lines vary in length from
>>> a few characters up to over 80, the average probably being 15. I had
>>> decided against using the [85] so as to not waste memory.
>>> [..]
>>
>> Just curious, in what world a few hundred bytes is a waste of memory
>> worthy of consideration? Are you targetting an embedded system or a
>> legacy computer with 640K memory (last century technology)? Don't get
>> me wrong, please, it's just that I have often enough seen real
>> (significant) time wasted on finding a solution to save a few
>> microseconds or a few [hundred] bytes, that usually in the end cannot be
>> accounted for. I can understand when students do that in the course of
>> their studies, but I don't understand the need for it when creating a
>> product for others to consume.
>
> I'm getting a lot of flack over this from many people on many lists. It's
> like ... if I don't do it the way everybody else does then I'm the one who's
> wrong. And because I look toward things which are important to me, and
> because I choose to not waste memory where it doesn't need to be wasted,
> while also simplifying the source code implementation of this task, that
> it is somehow a bad choice.

No, not a bad choice, by any means IMO. Just an uncommon one.
Everybody has their priorities. Advice we *give* in part serves as
affirmation of our being right (or at least in the right area). If
something is recommended against our convictions, we have a choice -
either to change our convictions or ignore the advice. And we make
those choices constantly. Such is life.

> FWIW, I had a working solution after getting the first access violation error
> in the Visual Studio debugger and realizing why I got it. It took me a few
> seconds to realize what was happening, even though it was unexpected. But,
> the whole issue was one of those things I wanted to better understand. It
> seemed (and still seems) a very silly imposition, that string literals
> created in that way (as data pointed to in a read-write array) should always
> be read-only unless they are explicitly cast through such a clunky syntax as
> compound literals, a feature that not all C compilers even support.

I hope you don't have to learn the hard way why such a silly imposition
exists.

> It was a mental exercise as much as anything else, a pursuit of a question,
> to satiate curiosity. I wound up not using the solution, but just
> discovering and testing it out. I learned many things in the process, not
> the least of which was how to integrate GCC and Visual C++ together in
> harmony. That alone was worth all the time I spent on it.

No argument here. Even if we don't gain anything, we always gain
experience.

>> I do not respond to top-posted replies, please don't ask
>
> Just curious, in what world would you deny giving help to someone in need
> simply because they top-posted? I had someone in 2011 or 2012 on the
> Trisquel mailing list tell me that I was a top poster and that he
> wasn't going to help me. I didn't even know what he was talking about
> and had to ask what that phrase "top poster" meant. When I found out
> I was floored that such a ridiculous barrier exists between the
> help-seekers, and the knowledge-holders on a forum like this.

It's my help to give, I can and may deny it on any basis I choose.
Would you help somebody who speaks rudely to you in the street or would
you simply turn away and keep minding your own business? In such a case
rudeness is in the eye of the beholder, of course. Similarly, I
perceive top-posting as rudeness and choose not to involve myself in a
message thread like that.

Incidentally, a way to have the last word in an argument with me *here*
is to top-post.

> It really taught me something ... a concept that is so amazingly important
> to only a select few, those who desire to divide people into groups of
> "them" (top posters) and "us" (the sensible lot). Seeing your tagline here
> in this forum I was again floored. I almost wrote something to you about
> it yesterday.
>
> Just so you know ... there's a better way, Victor. It's called "love".

Yes. So, if you care for *my* reply, now that you know that it is
important to *me*, and you can't get it if you top-post, you *might*
want to consider not top-post. Get it?

Practice what you preach.

And try not to preach.

> Tear down the barriers and come out and help people in love. And if you
> want to learn the fulness of love ... He is the man, named Jesus, who is
> the Christ, the only Savior of mankind.

<sigh>

V
--
I do not respond to top-posted replies, please don't ask




== 9 of 12 ==
Date: Fri, Jan 24 2014 9:40 am
From: Paavo Helde


"Hans-Peter" <Hans-Peter.Rampp@sap.com> wrote in
news:lbt8ip$dos$1@news.sap-ag.de:

>
> "Rick C. Hodgin" wrote in message
> news:0f20b7fc-b6b1-46d6-a733-bff0636cb5a7@googlegroups.com...
>>
>> 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.
>
> You can force that the list will be in the data segment by using
> #pragma data_seg() but this will only move the pointer array in to the
> data segment. Changing the strings to fixed size will do the job:

Seems it affects string literals as well. This program works fine for me
with VS2012:

#include <iostream>

#pragma data_seg(".xxx")

char* list[] = {
"one",
"two",
"three"};

int main() {
list[0][0]='t';
list[0][1]='e';
list[0][2]='n';
std::cout << list[0] << "\n";
}

Cheers
Paavo







== 10 of 12 ==
Date: Fri, Jan 24 2014 10:12 am
From: "Rick C. Hodgin"


On Friday, January 24, 2014 12:40:33 PM UTC-5, Paavo Helde wrote:
> Seems it affects string literals as well. This program works fine for me
> with VS2012:
>
> #include <iostream>
> #pragma data_seg(".xxx")
> char* list[] = {
> "one",
> "two",
> "three"
> };
> int main()
> {
> list[0][0]='t';
> list[0][1]='e';
> list[0][2]='n';
> std::cout << list[0] << "\n";
> }

Paavo, this one of the suggestions I tried. In VS2008 it gives the
same access violation error.

Best regards,
Rick C. Hodgin




== 11 of 12 ==
Date: Fri, Jan 24 2014 10:14 am
From: "Rick C. Hodgin"


On Friday, January 24, 2014 11:44:40 AM UTC-5, Victor Bazarov wrote:
> Yes. So, if you care for *my* reply, now that you know that it is
> important to *me*, and you can't get it if you top-post, you *might*
> want to consider not top-post. Get it?

Did I top-post? I ask because I honestly don't know. I was under the
impression that top-posting meant you posted above the quoted content.
But maybe my understanding is still incorrect.

Best regards,
Rick C. Hodgin




== 12 of 12 ==
Date: Fri, Jan 24 2014 10:33 am
From: Victor Bazarov


On 1/24/2014 1:14 PM, Rick C. Hodgin wrote:
> On Friday, January 24, 2014 11:44:40 AM UTC-5, Victor Bazarov wrote:
>> Yes. So, if you care for *my* reply, now that you know that it is
>> important to *me*, and you can't get it if you top-post, you *might*
>> want to consider not top-post. Get it?
>
> Did I top-post? I ask because I honestly don't know. I was under the
> impression that top-posting meant you posted above the quoted content.
> But maybe my understanding is still incorrect.

You did not top-post.

V
--
I do not respond to top-posted replies, please don't ask





==============================================================================
TOPIC: Boost
http://groups.google.com/group/comp.lang.c++/t/81738d66827a11c8?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Jan 24 2014 9:01 am
From: Oscar Chesnutt


J. Clarke wrote:

>> Please leave this thread, you do not contribute in any way.
>
> <plonk>

Indeed, this supposedly means that you gonna use a computer program
helping you not to read. Otherwise you just keep reading. You must be
terribly clever, like your friends.

We never got the answer to the Boost concern. Do I have to be stupid to
use that?




== 2 of 2 ==
Date: Fri, Jan 24 2014 9:33 am
From: Daniel


On Friday, January 24, 2014 12:01:15 PM UTC-5, Oscar Chesnutt wrote:
>
> We never got the answer to the Boost concern. Do I have to be
> stupid to use that?

Not at all. Even if you are not stupid, you can still use it.
Hope that helps.

Daniel





==============================================================================

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

No comments: