Friday, January 30, 2015

Digest for comp.lang.c++@googlegroups.com - 25 updates in 7 topics

Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Jan 29 10:59PM -0500


>> What is your goal for asking these questions?
 
> Teasing you.
 
> No, but seriously: I'm simply asking about good techniques. Recommend to me a book, framework, methodology, technique, ...
you might get more useful answers if you describe your particular target
platform and what it provides in terms of OS, programming interfaces,
C++ implementations, hardware capabilities, drivers for the devices of
your interest and the of industrial automation app you are trying to create.
jononanon@googlemail.com: Jan 29 11:51PM -0800

On Friday, January 30, 2015 at 4:59:52 AM UTC+1, Pavel wrote:
> platform and what it provides in terms of OS, programming interfaces,
> C++ implementations, hardware capabilities, drivers for the devices of
> your interest and the of industrial automation app you are trying to create.
 
Basically I'm thinking of applications that can leverage a lot of C++'s powers.
 
Things like a generic framework, for controlling automatic vacuum cleaners and similar robots. But it should be so well-designed generic that I can easily transfer it to a small off-road vehicle.
 
Or (probably simpler) a cocktail machine, where I can design input-recipes in a text-based from; and load them via the webserver-interface.
 
Or a framework for automatic modern washing machines. It should work with different hardware-types, have a nice user interface, allow the loading of washing-steps in a text-based form (that you load over the machine's webserver).
 
Or a Drone project.
 
Or a Mars Rover. (except that I do NOT have the requirement that it must work on Mars!). Yes I think that's a good example.
A generic Rover framework. One that is good enough that I can adapt it to become e.g. an automatic lawn-mower.
 
Stuff like that...
 
Basically I'm looking for the C++ book, that you'd recommend the junior C++ team-members of a Mars-Rover team should read...
... with the aim of doing really great software-architecture work and creating a superb and easily-maintainable system.
 
Basically the book that a world-class C++ programmer might write, after dedicatedly playing with a Beaglebone Black for a year, and focusing strongly on hardware-related themes such as timers, concurrency, states, safety-concept, maintainability, hardware-extensibility, ... and also including ways of tackling low-level requirements such as : recurring tasks, messaging, and message-passing, signals, callbacks,
and handling it with nice patterns.
 
I've just realized... such a book does not exist yet.
 
I guess I'm finished and will just wait and see what happens in the future...
 
 
I'd love to see a C++ group playing with Beaglebone Blacks, doing blog-posts on these things... and a vibrant community...
 
Because: just being able to get a light to blink with some C-code is far away from organizing an industrial or embedded project. I'm sure that leveraging C++, one can really do some great things in this area.
PS: the whole internet-of-things theme is also interesting in this respect. I want to run C++ code in gadgets and not use crazy stuff like javascript (https://tessel.io/).
David Brown <david.brown@hesbynett.no>: Jan 30 09:06AM +0100

> Rover framework. One that is good enough that I can adapt it to
> become e.g. an automatic lawn-mower.
 
> Stuff like that...
 
What you are asking for does not - and /cannot/ - exist. The range is
too great. I have worked on embedded systems with 2 GB ram running
Linux - and systems with 32 bytes of ram (yes, /bytes/ - not KB, MB, or
GB). In a fancy washing machine you will have a powerful board
controlling a touch screen - but you will also have tiny processors
controlling pumps and motors.
 
What you want is like asking for a container that is suitable for the
pencils on your desk, but should be easily adaptable to shipping cars
across the pacific and collecting moon rocks.
Wouter van Ooijen <wouter@voti.nl>: Jan 30 10:52AM +0100

> A generic Rover framework. One that is good enough that I can adapt it to become e.g. an automatic lawn-mower.
 
> Stuff like that...
 
> Basically I'm looking for the C++ book, that you'd recommend the junior C++ team-members of a Mars-Rover team should read...
 
There should be no junior on such a team.
 
> ... with the aim of doing really great software-architecture work and creating a superb and easily-maintainable system.
 
Sorry, there is no silver bullet, and likewise there is no one book that
will teach you how to do a such a very difficult thing the right way.
There are lots of books, talks on youtube, blogs, articles, etc. on this
topic. Read and apply as much as you can, and learn from it. In the long
run your exeperience might help the industry a little step further.
 
> Basically the book that a world-class C++ programmer might write, after dedicatedly playing with a Beaglebone Black for a year, and focusing strongly on hardware-related themes such as timers, concurrency, states, safety-concept, maintainability, hardware-extensibility, ... and also including ways of tackling low-level requirements such as : recurring tasks, messaging, and message-passing, signals, callbacks,
> and handling it with nice patterns.
 
World-class C++ programmers tend to know their limitations and focus on
more limited fields. Start by listening to every youtube talk by
Stroustrup, then broaden you reach by listening to the talks of guys
that appear at the same conferences. (Scott Meyers, Herb Sutter, ...)
 
Wouter van Ooijen
scott@slp53.sl.home (Scott Lurndal): Jan 30 04:23PM

>more limited fields. Start by listening to every youtube talk by
>Stroustrup, then broaden you reach by listening to the talks of guys
>that appear at the same conferences. (Scott Meyers, Herb Sutter, ...)
 
I wonder if these guys, who write about C++, have actually written
real-world production applications in C++?
 
The old (and insulting) expression "Those do can, do, those who can't, teach"
comes to mind :-).
jononanon@googlemail.com: Jan 30 08:55AM -0800

Just found this:
 
http://accu.org/index.php/conferences/accu_conference_2008/accu2008_sessions#C++%20for%20Embedded%20Systems
Slides:
http://accu.org/content/conf2008/Vollmann-embcpp08.pdf
(http://www.vollmann.ch/de/presentations/index.html)
 
Also:
http://www.artima.com/shop/effective_cpp_in_an_embedded_environment
Wouter van Ooijen <wouter@voti.nl>: Jan 30 06:02PM +0100

Scott Lurndal schreef op 30-Jan-15 om 5:23 PM:
> real-world production applications in C++?
 
> The old (and insulting) expression "Those do can, do, those who can't, teach"
> comes to mind :-).
 
That obviously bait, but there is a lot of (unavoidable) truth in it:
those who are full-time coders don't have time to spare to be good
speakers or authors, and vice versa.
 
But Strustroup and Meyers are good communicators, and they listen very
carefully to what the full-time coders ask, so they are worth reading
and listening to.
 
And me? I am a teacher...
Wouter
woodbrian77@gmail.com: Jan 30 11:49AM -0800

On Friday, January 30, 2015 at 11:02:41 AM UTC-6, Wouter van Ooijen wrote:
 
> But Strustroup and Meyers are good communicators, and they listen very
> carefully to what the full-time coders ask, so they are worth reading
> and listening to.
 
I'd add Andrei Alexandrescu to the list. I get a kick
out of him and Scott Meyers. Chandler Carruth is
knowledgeable and funny also.
 
 
 
> And me? I am a teacher...
 
Thank G-d for teachers. I owe a great debt to
my teachers.
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
scott@slp53.sl.home (Scott Lurndal): Jan 30 04:29PM

>> 13 packets transmitted, 0 packets received, 100.0% packet loss
>> ~ $
 
>> How sad is all this.
 
."
 
>A web server doesn't necessarily answer to control messages ("pings"),
>as you may already know. But the content is there.
 
In fact, ICMP packets are almost universally blocked at the
edge ingress gateway, for very good reasons. The yahoo servers
are a notable exception.
Lynn McGuire <lmc@winsim.com>: Jan 30 12:53PM -0600

On 1/30/2015 10:29 AM, Scott Lurndal wrote:
 
> In fact, ICMP packets are almost universally blocked at the
> edge ingress gateway, for very good reasons. The yahoo servers
> are a notable exception.
 
C:\dii>ping google.com
 
Pinging google.com [64.233.168.101] with 32 bytes of data:
Reply from 64.233.168.101: bytes=32 time=21ms TTL=42
Reply from 64.233.168.101: bytes=32 time=20ms TTL=42
Reply from 64.233.168.101: bytes=32 time=20ms TTL=42
Reply from 64.233.168.101: bytes=32 time=20ms TTL=42
 
Ping statistics for 64.233.168.101:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 20ms, Maximum = 21ms, Average = 20ms
 
Lynn
woodbrian77@gmail.com: Jan 30 11:15AM -0800

On Friday, January 30, 2015 at 12:53:32 PM UTC-6, Lynn McGuire wrote:
> Approximate round trip times in milli-seconds:
> Minimum = 20ms, Maximum = 21ms, Average = 20ms
 
> Lynn
 
 
I can ping wnd.com and twitter.com.
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
Rosario193 <Rosario@invalid.invalid>: Jan 30 11:04AM +0100

On Thu, 29 Jan 2015 10:06:05 -0600, Christopher Pisz wrote:
>> for( i=sizeof(int)-1; ; --i )
>You win the ugly code of the week award.
 
>What's wrong with #include <cstdio> ?
 
i have one old C++ compiler that allow that
 
>Defining your own types as primitive types accomplishes what? One more
>search someone has to do when looking at your code.
 
here there is not "stdint.h" where would it be uint32_t
 
>Naming all variables with a single or double letter rather than a
>meaningful name.
 
not for the words one always use
 
>(void) parameters instead of (), for what purpose? I thought you were
>trying to save keystrokes.
 
i want sys call "int main(void)"
and not call "int main()"
 
>more than one statement on the same line
 
instruction that are connected, i sometime write in the same line
 
>Statements sometimes on same line with brackets, sometimes not,
>sometimes no brackets at all. At least be consistent with ugly style.
 
they call it readability...
Rosario193 <Rosario@invalid.invalid>: Jan 30 11:05AM +0100

On Thu, 29 Jan 2015 14:48:02 +0100, jak wrote:
> Res = LT[Byte % Base] + Res;
> return Res;
>}
 
#include <stdio.h>
#include <string.h>
#include <limits.h>
 
#define u8 unsigned char
#define u32 unsigned
#define i32 int
#define P printf
#define F for
#define R return
 
 
// result ok if return one number > 0
// that is the len of the string result even if there is some 0 in it
i32 uToA(u8* rstr, u32 rstrsize, u32 argnumber, u32 base)
{u32 i, j, k;
u8 tmp[64];
u8 str[64]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
if(rstr==0) R -1;
if(rstrsize > 0xFFFFFFF) R -1;
rstr[0]=0;
if(base<=1 || base>255) R -1;
 
F( i=0, tmp[0]=0; argnumber; ++i)
{tmp[i]=argnumber%base; argnumber/=base;}
if(i+2>rstrsize) R -2;
if(i!=0) --i;
if(base<=36)
{F(k=0, j=i; ;--j, ++k)
{rstr[k]=str[tmp[j]];
if(j==0) break;
}
}
else {F(k=0, j=i; ;--j, ++k)
{rstr[k]=tmp[j];
if(j==0) break;
}
}
++k; rstr[k]=0;
R k;
}
 
 
 
int main(void)
{u32 m=0x12f5e188, i, x, base;
i32 r;
u8 result[128]; // 0..126 127[0]
 
F(base=0; base<=256; ++base)
{r=uToA(result, 128, m, base);
P("base=%u r=%u ", base, r);
if(r>0)
{F(i=0; i<(u32)r; ++i)
{if(base<=36) P("%c", result[i]);
else {x=result[i];
P("%x", x);
}
if(base>36 && i!=(u32)r-1) P("_");
}
}
if(base!=0 && base%3==0) P("\n");
else P("#");
if(base>=2 && base<=36 && strlen(result)!=(u32)r)
P("Find Error base=%u", base);
}
P("\n");
R 0;
}
 
base=0 r=4294967295 #base=1 r=4294967295
#base=2 r=29 10010111101011110000110001000
#base=3 r=18 211011120100120120
base=4 r=15 102331132012020
#base=5 r=13 1122413311234#base=6 r=11 51322023240
base=7 r=11 10611560514#base=8 r=10 2275360610#base=9 r=9 734510516
base=10 r=9 318103944#base=11 r=9 15361A224#base=12 r=8 8A647B20
base=13 r=8 50B991B2#base=14 r=8 30367144#base=15 r=8 1CDD8049
base=16 r=8 12F5E188#base=17 r=7 D30B6BC#base=18 r=7 9664A56
base=19 r=7 6E8HB6G#base=20 r=7 4J82JH4#base=21 r=7 3EIDG2I
base=22 r=7 2HFKBC4#base=23 r=7 239GIG6#base=24 r=7 1FMINJ0
base=25 r=7 17E8G7J#base=26 r=7 10K2JP2#base=27 r=6 M4F9FF
base=28 r=6 IDEON4#base=29 r=6 FELQPF#base=30 r=6 D2LIOO
base=31 r=6 B3DQEH#base=32 r=6 9FBOC8#base=33 r=6 847NFF
base=34 r=6 701EEC#base=35 r=6 61YBO4#base=36 r=6 59E2KO
base=37 r=6 4_15_1b_2_9_21#base=38 r=6 4_0_15_7_16_10#base=39 r=6
3_14_13_17_c_f
 
base=40 r=6 3_4_a_e_26_18#base=41 r=6 2_1e_17_13_26_20#base=42 r=6
2_12_9_19_1_1
2
base=43 r=6 2_7_1_29_3_6#base=44 r=6 1_28_26_d_27_4#base=45 r=6
1_20_19_26_10_18
 
base=46 r=6 1_19_2_4_1f_6#base=47 r=6 1_12_8_2a_1c_1#base=48 r=6
1_b_2c_11_2d_18
 
base=49 r=6 1_6_8_29_5_b#base=50 r=6 1_0_2c_29_1c_2c#base=51 r=5
2f_1_2_20_c
base=52 r=5 2b_1a_11_33_1c#base=53 r=5 28_10_24_1d_b#base=54 r=5
25_16_9_7_2a
base=55 r=5 22_29_35_12_4#base=56 r=5 20_13_14_b_20#base=57 r=5
1e_7_27_e_36
base=58 r=5 1c_6_15_c_2c#base=59 r=5 1a_e_32_36_10#base=60 r=5
18_20_2a_c_18
base=61 r=5 16_3b_1b_32_2e#base=62 r=5 15_20_2d_16_30#base=63 r=5
14_c_b_7_3c
base=64 r=5 12_3d_1e_6_8#base=65 r=5 11_35_14_38_36#base=66 r=5
10_32_1e_28_30
base=67 r=5 f_34_2b_42_4#base=68 r=5 e_3b_2e_7_c#base=69 r=5
e_2_16_24_6
base=70 r=5 d_11_1d_c_4#base=71 r=5 c_24_37_18_11#base=72 r=5
b_3c_12_2e_18
base=73 r=5 b_e_33_48_14#base=74 r=5 a_2d_0_29_46#base=75 r=5
a_4_1_3c_45
base=76 r=5 9_28_31_1e_10#base=77 r=5 9_3_3c_10_4#base=78 r=5
8_2e_19_19_36
base=79 r=5 8_d_f_2_10#base=80 r=5 7_3d_17_3b_18#base=81 r=5
7_1f_2e_5_f
base=82 r=5 7_2_4c_3c_20#base=83 r=5 6_3a_1b_34_35#base=84 r=5
6_20_3a_3f_3c
base=85 r=5 6_7_53_13_1d#base=86 r=5 5_46_a_17_6#base=87 r=5
5_30_6_12_f
base=88 r=5 5_1a_45_29_30#base=89 r=5 5_6_14_32_37#base=90 r=5
4_4c_20_8_18
base=91 r=5 4_3a_b_40_43#base=92 r=5 4_28_2f_f_34#base=93 r=5
4_17_2c_19_30
base=94 r=5 4_6_5c_54_30#base=95 r=5 3_56_1_5c_36#base=96 r=5
3_47_34_2e_48
base=97 r=5 3_39_34_2e_a#base=98 r=5 3_2b_60_2_3c#base=99 r=5
3_1e_53_1b_f
base=100 r=5 3_12_a_27_2c#base=101 r=5 3_5_4b_3d_0#base=102 r=5
2_5f_4d_10_c
base=103 r=5 2_55_b_23_53#base=104 r=5 2_4a_52_33_50#base=105 r=5
2_40_52_65_27
base=106 r=5 2_37_9_e_40#base=107 r=5 2_2d_47_2e_6#base=108 r=5
2_24_38_1e_60
base=109 r=5 2_1b_45_12_58#base=110 r=5 2_12_6d_40_4#base=111 r=5
2_a_42_3_21
base=112 r=5 2_2_2f_5_58#base=113 r=5 1_6b_34_17_11#base=114 r=5
1_64_51_7_36
base=115 r=5 1_5e_12_1a_1d#base=116 r=5 1_57_5c_23_2c#base=117 r=5
1_51_47_6c_f
base=118 r=5 1_4b_47_56_10#base=119 r=5 1_45_5b_2d_2e#base=120 r=5
1_40_a_42_18
base=121 r=5 1_3a_43_70_1a#base=122 r=5 1_35_16_19_2e#base=123 r=5
1_2f_74_c_72
base=124 r=5 1_2a_68_2a_30#base=125 r=5 1_25_6c_51_45#base=126 r=5
1_21_2_62_3c
base=127 r=5 1_1c_25_3d_3b#base=128 r=5 1_17_57_43_8#base=129 r=5
1_13_17_57_6
base=130 r=5 1_e_66_5d_36#base=131 r=5 1_a_41_3a_32#base=132 r=5
1_6_28_56_30
base=133 r=5 1_2_1c_13_82#base=134 r=4 84_1b_64_4#base=135 r=4
81_27_23_45
base=136 r=4 7e_3e_47_50#base=137 r=4 7b_61_32_52#base=138 r=4
79_5_57_6
base=139 r=4 76_3e_15_51#base=140 r=4 73_81_6f_4#base=141 r=4
71_43_38_30
base=142 r=4 6f_d_76_58#base=143 r=4 6c_6f_8a_f#base=144 r=4
6a_4c_5f_18
base=145 r=4 68_31_73_2c#base=146 r=4 66_1f_24_14#base=147 r=4
64_14_84_3c
base=148 r=4 62_12_5e_90#base=149 r=4 60_18_35_77#base=150 r=4
5e_25_8e_90
base=151 r=4 5c_3b_2f_60#base=152 r=4 5a_58_35_10#base=153 r=4
58_7c_92_72
base=154 r=4 57_f_8_4#base=155 r=4 55_41_53_4f#base=156 r=4
53_7b_33_84
base=157 r=4 52_1f_36_79#base=158 r=4 50_66_50_10#base=159 r=4
4f_15_73_75
base=160 r=4 4d_69_95_68#base=161 r=4 4c_24_8_90#base=162 r=4
4a_85_2_60
base=163 r=4 49_49_79_99#base=164 r=4 48_13_1e_20#base=165 r=4
46_86_2a_72
base=166 r=4 45_59_96_88#base=167 r=4 44_32_c_6#base=168 r=4
43_e_73_90
base=169 r=4 41_98_76_91#base=170 r=4 40_7f_9_72#base=171 r=4
3f_69_76_a8
base=172 r=4 3e_58_61_5c#base=173 r=4 3d_4b_6b_15#base=174 r=4
3c_42_8b_66
base=175 r=4 3b_3e_b_90#base=176 r=4 3a_3d_40_88#base=177 r=4
39_40_74_4b
base=178 r=4 38_47_9e_90#base=179 r=4 37_53_5_1#base=180 r=4
36_62_4_18
base=181 r=4 35_74_97_40#base=182 r=4 34_8b_4d_9e#base=183 r=4
33_a5_8a_a8
base=184 r=4 33_b_91_90#base=185 r=4 32_2c_5a_90#base=186 r=4
31_50_98_30
base=187 r=4 30_78_8a_72#base=188 r=4 2f_a4_2a_30#base=189 r=4
2f_16_2c_7b
base=190 r=4 2e_47_8d_36#base=191 r=4 2d_7c_88_81#base=192 r=4
2c_b5_17_48
base=193 r=4 2c_2f_b3_ba#base=194 r=4 2b_6e_17_a#base=195 r=4
2a_af_7f_36
base=196 r=4 2a_30_63_3c#base=197 r=4 29_77_80_a4#base=198 r=4
28_c2_d_72
base=199 r=4 28_48_90_38#base=200 r=4 27_98_77_90#base=201 r=4
27_22_85_8a
base=202 r=4 26_77_b6_0#base=203 r=4 26_5_39_66#base=204 r=4
25_5f_a1_c
base=205 r=4 24_bd_51_72#base=206 r=4 24_50_11_ba#base=207 r=4
23_b2_ad_6
base=208 r=4 23_48_81_b8#base=209 r=4 22_b0_5a_5c#base=210 r=4
22_49_32_90
base=211 r=4 21_b6_6_85#base=212 r=4 21_51_a6_40#base=213 r=4
20_c3_66_9f
base=214 r=4 20_62_17_6#base=215 r=4 20_1_8a_31#base=216 r=4
1f_7a_f_60
base=217 r=4 1f_1c_51_ac#base=218 r=4 1e_99_76_58#base=219 r=4
1e_3e_79_5d
base=220 r=4 1d_c0_57_4#base=221 r=4 1d_68_b_50#base=222 r=4
1d_10_70_90
base=223 r=4 1c_98_a7_13#base=224 r=4 1c_43_aa_c8#base=225 r=4
1b_d0_78_45
base=226 r=4 1b_7e_b_82#base=227 r=4 1b_2c_43_da#base=228 r=4
1a_bf_3c_a8
base=229 r=4 1a_6f_d7_2c#base=230 r=4 1a_21_46_90#base=231 r=4
19_ba_52_51
base=232 r=4 19_6e_11_a0#base=233 r=4 19_22_69_e4#base=234 r=4
18_c1_70_84
base=235 r=4 18_78_21_bd#base=236 r=4 18_2f_66_10#base=237 r=4
17_d4_4f_ae
base=238 r=4 17_8d_c9_2e#base=239 r=4 17_47_e2_ca#base=240 r=4
17_2_99_18
base=241 r=4 16_ae_d9_5b#base=242 r=4 16_6b_b1_1a#base=243 r=4
16_29_1c_b1
base=244 r=4 15_db_c_a8#base=245 r=4 15_9a_80_6d#base=246 r=4
15_5a_81_72
base=247 r=4 15_1b_c_36#base=248 r=4 14_d4_15_30#base=249 r=4
14_96_9b_db
base=250 r=4 14_59_a5_c2#base=251 r=4 14_1d_2f_62#base=252 r=4
13_dd_31_3c
base=253 r=4 13_a2_aa_d5#base=254 r=4 13_68_9d_ba#base=255 r=4
13_2f_6_72
base=256 r=4294967295 #
Christopher Pisz <nospam@notanaddress.com>: Jan 30 10:27AM -0600

On 1/30/2015 4:04 AM, Rosario193 wrote:
>> You win the ugly code of the week award.
 
>> What's wrong with #include <cstdio> ?
 
> i have one old C++ compiler that allow that
 
Upgrade your compiler to the year 2015. You are posting example code for
someone else to use.
 
 
>> Naming all variables with a single or double letter rather than a
>> meaningful name.
 
> not for the words one always use
 
Every single variable you have in your code is a single or double
letter. No one knows wtf aa=a; means without having to study your entire
listing. employeePay = twoWeekSalary is immediately obvious. You are
writing C++ (supposedly) code for humans to read. You are not working in
matlab.
 
 
>> trying to save keystrokes.
 
> i want sys call "int main(void)"
> and not call "int main()"
 
Why? Are you posting to a C++ newsgroup? Are you programming modern C++?
 
 
>> Statements sometimes on same line with brackets, sometimes not,
>> sometimes no brackets at all. At least be consistent with ugly style.
 
> they call it readability...
 
That's hilarious.
Christopher Pisz <nospam@notanaddress.com>: Jan 30 10:32AM -0600

On 1/30/2015 4:05 AM, Rosario193 wrote:
> #define F for
> #define R return
 
>SNIP
 
For Pete's sake, just stop. Go back to 1970.
Rosario193 <Rosario@invalid.invalid>: Jan 30 07:21PM +0100

On Fri, 30 Jan 2015 11:05:13 +0100, Rosario193 wrote:
> if(j==0) break;
> }
> }
 
all these swap show that arabs representation for number, or little
endian
is the right way...
and we have only wrong
 
Rosario193 <Rosario@invalid.invalid>: Jan 30 07:54PM +0100

On Fri, 30 Jan 2015 11:05:13 +0100, Rosario193 wrote:
 
some corrections... base 256 shoule be ok too...
 
#include <stdio.h>
#include <string.h>
#include <limits.h>
 
#define u8 unsigned char
#define u32 unsigned
#define i32 int
#define P printf
#define F for
#define R return
 
 
// result ok if return one number > 0
i32 uToA(u8* rstr, u32 rstrsize, u32 argnumber, u32 base)
{u32 i, j, k;
u8 tmp[64];
u8 str[64]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
if(rstr==0) R -1;
if(rstrsize > 0xFFFFFFF) R -1;
rstr[0]=0;
if(base<=1 || base>256) R -1;
 
F( i=0, tmp[0]=0; argnumber; ++i)
{tmp[i]=argnumber%base; argnumber/=base;}
if(i+2>rstrsize) R -2;
if(i!=0) --i;
if(base<=36)
{F(k=0, j=i; ;--j, ++k)
{rstr[k]=str[tmp[j]];
if(j==0) break;
}
}
else {F(k=0, j=i; ;--j, ++k)
{rstr[k]=tmp[j];
if(j==0) break;
}
}
++k; rstr[k]=0;
R k;
}
 
 
int main(void)
{u32 m=0x12f5e188, i, x, base;
i32 r;
u8 result[128]; // 0..126 127[0]

if(CHAR_BIT!=8 || sizeof(u32)!=4)
{P("this can not to run here\n"); R 0;}
 
F(base=0; base<=257; ++base)
{r=uToA(result, 128, m, base);
P("base=%u r=%u ", base, r);
if(r>0)
{F(i=0; i<(u32)r; ++i)
{if(base<=36) P("%c", result[i]);
else {x=result[i];
P("%u", x);
}
if(base>36 && i!=(u32)r-1) P("_");
}
}
if(base!=0 && base%3==0) P("\n");
else P("#");
if(base>=2 && base<=36 && strlen(result)!=(u32)r)
P("Find Error base=%u", base);
}
P("\n");
R 0;
}
Rosario193 <Rosario@invalid.invalid>: Jan 30 08:04PM +0100

On Thu, 29 Jan 2015 14:48:02 +0100, jak wrote:
 
 
> if (Base > 1 && Base <= 16)
> for (; Byte > 0; Byte /= Base)
> Res = LT[Byte % Base] + Res;
 
here just above the compiler said one error, so not compile...
i think the reason why is the const above...
so i wrote it this
 
Res = (char) LT[Byte % Base] + Res;
 
and compile...
 
Rosario193 <Rosario@invalid.invalid>: Jan 30 08:13PM +0100

On Thu, 29 Jan 2015 14:48:02 +0100, jak wrote:
 
your program print:
 
Base 2:
1) 10001000
2) 11100001
3) 11110101
4) 10010
 
Premere un tasto per continuare . . .
 
Base 3:
1) 12001
2) 22100
3) 100002
4) 200
 
Premere un tasto per continuare . . .
 
Base 4:
1) 2020
2) 3201
3) 3311
4) 102
 
Premere un tasto per continuare . . .
 
Base 5:
1) 1021
2) 1400
3) 1440
4) 33
 
Premere un tasto per continuare . . .
 
Base 6:
1) 344
2) 1013
3) 1045
4) 30
 
Premere un tasto per continuare . . .
 
Base 7:
1) 253
2) 441
3) 500
4) 24
 
Premere un tasto per continuare . . .
 
Base 8:
1) 210
2) 341
3) 365
4) 22
 
Premere un tasto per continuare . . .
 
Base 9:
1) 161
2) 270
3) 302
4) 20
 
Premere un tasto per continuare . . .
 
Base 10:
1) 136
2) 225
3) 245
4) 18
 
Premere un tasto per continuare . . .
 
Base 11:
1) 114
2) 195
3) 203
4) 17
 
Premere un tasto per continuare . . .
 
Base 12:
1) B4
2) 169
3) 185
4) 16
 
Premere un tasto per continuare . . .
 
Base 13:
1) A6
2) 144
3) 15B
4) 15
 
Premere un tasto per continuare . . .
 
Base 14:
1) 9A
2) 121
3) 137
4) 14
 
Premere un tasto per continuare . . .
 
Base 15:
1) 91
2) 100
3) 115
4) 13
 
Premere un tasto per continuare . . .
 
Base 16:
1) 88
2) E1
3) F5
4) 12
 
Premere un tasto per continuare . . .
 
my print:
base=0 r=4294967295 #base=1 r=4294967295 #base=2 r=29
10010111101011110000110001
000#base=3 r=18 211011120100120120
base=4 r=15 102331132012020#base=5 r=13 1122413311234#base=6 r=11
51322023240
base=7 r=11 10611560514#base=8 r=10 2275360610#base=9 r=9 734510516
base=10 r=9 318103944#base=11 r=9 15361A224#base=12 r=8 8A647B20
base=13 r=8 50B991B2#base=14 r=8 30367144#base=15 r=8 1CDD8049
base=16 r=8 12F5E188
 
so result in other base except 16 swapped are different...
James Moe <jimoeDESPAM@sohnen-moe.com>: Jan 30 11:07AM -0700

Hello,
I am looking into some code for DNS MX lookup. It compiles but is
missing a library for building the executable.
Can anyone suggest which library contains the missing functions?
 
c++ mx-lookup.cpp
/tmp/ccRz24GU.o: In function `MXLookup(char const*)':
mx-lookup.cpp:(.text+0x99): undefined reference to `__res_query'
mx-lookup.cpp:(.text+0xc6): undefined reference to `ns_initparse'
mx-lookup.cpp:(.text+0x10a): undefined reference to `ns_parserr'
mx-lookup.cpp:(.text+0x196): undefined reference to `ns_get16'
mx-lookup.cpp:(.text+0x1cd): undefined reference to `ns_name_uncompress'
collect2: error: ld returned 1 exit status
 
 
--
James Moe
jmm-list at sohnen-moe dot com
"Öö Tiib" <ootiib@hot.ee>: Jan 30 10:31AM -0800

On Friday, 30 January 2015 20:07:28 UTC+2, James Moe wrote:
> mx-lookup.cpp:(.text+0x196): undefined reference to `ns_get16'
> mx-lookup.cpp:(.text+0x1cd): undefined reference to `ns_name_uncompress'
> collect2: error: ld returned 1 exit status
 
You should link with -lresolv (libresolv)
James Moe <jimoeDESPAM@sohnen-moe.com>: Jan 30 12:08PM -0700

On 01/30/2015 11:31 AM, Öö Tiib wrote:
> You should link with -lresolv (libresolv)
 
Thank you!
 
--
James Moe
jmm-list at sohnen-moe dot com
Lynn McGuire <lmc@winsim.com>: Jan 30 01:00PM -0600

"Experimenting with a Proposed Standard Drawing Library for the C++ language"
https://msopentech.com/blog/2015/01/28/experimenting-with-a-proposed-standard-gui-for-the-c-language/
 
C++ has needed a standard drawing library for a LONG time! This may take hold with Sutter behind it.
http://isocpp.org/blog/2014/01/n3888
 
Now C++ needs a standard user interface library.
 
Lynn
G DeR <me@myworld.com>: Jan 30 07:25PM +0100

Il 29/01/2015 21:23, Stefan Ram ha scritto:
 
> A compiler, however, is not an implementation, nor does
> it contain an implementation. So it would usually be
> false to list a compiler as an implementation.
 
Pedantry can sometimes provide two mutually exclusive indications
on one's personality. In one case, the picture is that of a person
devoted to a deep understanding of any subject, whose knowledge
originates from scrupulous attention to every detail, which is then
applied constantly, in any domain, as an established habit. In the
other case, such attitude highlights one's attention to unnecessary
and redudant quibbles, as evidence of a poor level of insight and low
consideration for other people, fact that results in a clumsy attempt
to show off one's own presumed insightfulness, while it inevitably
translates to childish exhibitionism and tangible superficiality to
other people's eyes.
 
--
Yet another musician
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Jan 29 10:31PM -0500

Jorgen Grahn wrote:
 
> Sure, that's what we're both talking about: how to give clues in the
> code to help people remember what the function does, while keeping the
> code as a whole readable.
I am not certain I understand the challenge here. I thought, if a person
is likely to guess correctly what a function does, it plainly
contributes to the readability. I am all for the good prototypes for a
number of reasons but I do not see how they can significantly help to
understand what the function does. At a function call or other reference
site, the prototype or signature is not always obvious, especially in C++.
> and needs to be seen in that context.
 
> But yes, if you take one of my signatures and strip off everything but
> the function name, you'll end up with a not very useful name!
It's not me, it's the reference site that one will be reading and at
which there may be less than perfect information about the prototype.
Understanding reference site is important because it's the most often
context where the reader would meet a name of useful function.
>> it as a part of an initializer.
 
> I don't think the risk is normally very high -- and I'm prepared to
> make exceptions for special cases.
The problem is that when one selects a name for a new publicly
accessible function he or she has no control on how the function will be
used. If the function turns out to be really useful, it is only more
probable that people might eventually want to pass it as an argument
etc. or initialize some pointer with it. Specifically it is almost
common to store setters in a map with a textual key to fill up some data
structures read from external sources such as configuration files. By
the time such usage is needed, it might be too late for the name change.
> /Jorgen
 
-Pavel
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: