Go to advanced search

by jahboater
Thu May 04, 2017 12:12 pm
Forum: C/C++
Topic: New Gcc 7.1, his build sources result success with B model A
Replies: 52
Views: 7896

Re: New Gcc 7.1, his build sources result success with B mod

crossover post, I just added the quotes above - because, as people said, when installing a newer GCC then the stability of the whole system is perhaps shaky. OK there may have been some bad wording somewhere in all that and several different issues were being discussed. I can state for a fact that ...
by jahboater
Thu May 04, 2017 12:02 pm
Forum: C/C++
Topic: New Gcc 7.1, his build sources result success with B model A
Replies: 52
Views: 7896

Re: New Gcc 7.1, his build sources result success with B mod

Of course I as an end-user am not interested in recompiling the whole GCC with the Linux kernel I don't know what "with the Linux kernel" means? and then be responsible for the fail-safety of the entire system, Why does installing a compiler affect anything like that? You don't recompile the kernel...
by jahboater
Thu May 04, 2017 11:07 am
Forum: C/C++
Topic: New Gcc 7.1, his build sources result success with B model A
Replies: 52
Views: 7896

Re: New Gcc 7.1, his build sources result success with B mod

because of 25000 packages depending on that upgrade to work safely and stable with the Linux kernel. +1 to JamesH's comment. Not a single one of those 25000 existing packages will be affected by a newer compiler. Simply because you don't compile them! To JamesH The repos already contain several ver...
by jahboater
Wed May 03, 2017 5:43 pm
Forum: C/C++
Topic: Writing clean code isn't hard!
Replies: 138
Views: 13971

Re: Writing clean code isn't hard!

PeterO wrote: PS: Latest code draws and animates this:
Image
Impressive. I guess it shows the paper tape running through the reader and the algol on it being printed out at the same time.
by jahboater
Wed May 03, 2017 4:54 pm
Forum: C/C++
Topic: Writing clean code isn't hard!
Replies: 138
Views: 13971

Re: Writing clean code isn't hard!

<Edit> Just looked in K&R C (2nd edition), that gives an example where functions are declared in a header without using extern, so that's ~30 years of not needing it at least (yet gcc still provides the standard libraries with explicit extern function prototypes). Perhaps its to help readability - ...
by jahboater
Wed May 03, 2017 3:32 pm
Forum: C/C++
Topic: Writing clean code isn't hard!
Replies: 138
Views: 13971

Re: Writing clean code isn't hard!

My code will (eventually) run on Raspbian and 64 bit PC Linux so it's probably going to be wrong on one platform or another :lol: PS: Now upto 10,300 lines of code with no warnings. I think you will be fine, you have done it the right way round (32-bit first). long a; unsigned int b; a = b; // will...
by jahboater
Wed May 03, 2017 3:00 pm
Forum: C/C++
Topic: Writing clean code isn't hard!
Replies: 138
Views: 13971

Re: Writing clean code isn't hard!

PeterO wrote:Where do you stand on putting the previously necessary "extern" in front of function prototypes in header files ?
You've got me there, I didn't know it had changed :-(

I use "static" if the actual function definition is within the same compilation unit or "extern" iff its in a different one.
by jahboater
Wed May 03, 2017 12:34 pm
Forum: C/C++
Topic: Writing clean code isn't hard!
Replies: 138
Views: 13971

Re: Writing clean code isn't hard!

I can see the point of adding "assert()" statements early in a development as a way to prompt the programmer that there is an unhanded case that still needs to be considered and handled in the code. I think its two differing ways of thinking about assert. The above is not why I put them in (I use T...
by jahboater
Wed May 03, 2017 10:46 am
Forum: C/C++
Topic: Writing clean code isn't hard!
Replies: 138
Views: 13971

Re: Writing clean code isn't hard!

I sometimes do things like this to justify a cast. int a; unsigned int b; assert( a >= 0 ); b = (unsigned int)a; I can see where you're going with that, but it kind of says "I'm actually not sure that a will always be positive and I can't be bothered to work out when it might be negative, so I'm no...
by jahboater
Wed May 03, 2017 10:08 am
Forum: C/C++
Topic: Writing clean code isn't hard!
Replies: 138
Views: 13971

Re: Writing clean code isn't hard!

Well that's an interesting point ! The "character" held in ch is actually only 5 bits (it represents a character form a length of paper tape from an 1960's computer) so uint8_t seems the most appropriate type to use. Upper case only! (why not "char" by the way? reads better and sign extension will ...
by jahboater
Wed May 03, 2017 9:53 am
Forum: C/C++
Topic: Writing clean code isn't hard!
Replies: 138
Views: 13971

Re: Writing clean code isn't hard!

preferring instead to think about the limits of the values in variables and using appropriate types. This has worked fine for me for over 30 years. Yes indeed. And that sort of thought is still needed. If you are going to override a warning with a cast you are saying that you have actually done so....
by jahboater
Wed May 03, 2017 9:42 am
Forum: C/C++
Topic: Writing clean code isn't hard!
Replies: 138
Views: 13971

Re: Writing clean code isn't hard!

The only solution I've found that is warning free is to replace "ch += a;" with "ch = (uint8_t) (ch + a);" which seems nonsensical until you remember the integer promotion rules mentioned earlier). I think thats the only way of doing it - if ch really must be 8 bits. or perhaps this horrid macro! #...
by jahboater
Wed May 03, 2017 8:31 am
Forum: C/C++
Topic: Writing clean code isn't hard!
Replies: 138
Views: 13971

Re: Writing clean code isn't hard!

Annoying isn't it! Especially as in your example the compiler must know that 0x10 + 0x20 is perfectly safe. As you know, in C types smaller than int are promoted to int for the expression, which is for processors like ARM that cannot correctly do 8-bit arithmetic (they only have 32-bit registers). T...
by jahboater
Wed May 03, 2017 7:25 am
Forum: Troubleshooting
Topic: Trying to use ssh
Replies: 1
Views: 380

Re: Trying to use ssh

I use:

ssh pi@192.168.1.11

You must have enabled ssh on the Pi first by placing a file called "ssh" in the boot FAT partition.

The default password for user pi is raspberry, you should change that.
by jahboater
Wed May 03, 2017 7:03 am
Forum: C/C++
Topic: GCC 7.1 released
Replies: 0
Views: 477

GCC 7.1 released

by jahboater
Tue May 02, 2017 7:52 am
Forum: Troubleshooting
Topic: execute script by pi after startup
Replies: 9
Views: 1184

Re: execute script by pi after startup

Try this then:

Code: Select all

python /home/pi/ledmatrix/ledmatrix.py /home/pi/ledmatrix/image.png & 
As noted above the environment is different, and its already root.

In you case it doesn't run in your home directory and so has no idea where the "ledmatrix" folder is - so you must give it the full path.
by jahboater
Tue May 02, 2017 6:33 am
Forum: Beginners
Topic: How fast can the GPIO be?
Replies: 4
Views: 829

Re: How fast can the GPIO be?

For C, use the pigpio library (already included with Raspbian)
http://abyz.co.uk/rpi/pigpio/
by jahboater
Tue May 02, 2017 6:27 am
Forum: Troubleshooting
Topic: execute script by pi after startup
Replies: 9
Views: 1184

Re: execute script by pi after startup

JustM3 wrote:

Code: Select all

sudo python /home/pi/ledmatrix/ledmatrix.py image.png & 

The .png file is a image that displays on the matrix board.
Where is the .png file? perhaps put the full path in, something like this:-

Code: Select all

sudo python /home/pi/ledmatrix/ledmatrix.py /home/pi/image.png & 
by jahboater
Sun Apr 30, 2017 12:31 pm
Forum: Troubleshooting
Topic: Why yours and not mine
Replies: 38
Views: 3630

Re: Why yours and not mine

mikerr wrote:

Code: Select all

 sudo sh -c 'unzip -qc 2017-04-10-raspbian-jessie-lite.zip >/dev/sde '
Probably the best yet, and "sh" is a link to "dash" which is around 1/10 of the size of bash.
by jahboater
Sun Apr 30, 2017 12:16 pm
Forum: Troubleshooting
Topic: Why yours and not mine
Replies: 38
Views: 3630

Re: Why yours and not mine

cp /bin/bash asroot
sudo chown root asroot
sudo chmod +s asroot
:|
by jahboater
Sun Apr 30, 2017 11:47 am
Forum: Beginners
Topic: GPU/CPU temperature limit for RPI3
Replies: 27
Views: 7580

Re: GPU/CPU temperature limit for RPI3

I know that these times are dependent on several factors, but the objective of my question is to know if it is worthy to put the fan on my RPI case or not. For example, if it varies from 5 to 3 years, maybe it is worthy for me not to use the fan. Its not worth using a fan unless you are into extrem...
by jahboater
Sun Apr 30, 2017 10:50 am
Forum: Troubleshooting
Topic: Why yours and not mine
Replies: 38
Views: 3630

Re: Why yours and not mine

Even though swapping dd for tee is still a bit messy to type, using unzip -c does save up to 4GB of wear and tear on your PC's SSD (if you care about that) and it does seem fast even though tee only uses an 8KB block size.
by jahboater
Sun Apr 30, 2017 10:42 am
Forum: Troubleshooting
Topic: Why yours and not mine
Replies: 38
Views: 3630

Re: Why yours and not mine

Martin Frezman wrote: $ sudo bash
# and then do your stuff here
and ^D to finish with.

or "sudo su" (two less characters to type :))

I chose tee because I don't like working in a root shell if I can avoid it.
Its a bit messy either way.
by jahboater
Sun Apr 30, 2017 10:29 am
Forum: Troubleshooting
Topic: Why yours and not mine
Replies: 38
Views: 3630

Re: Why yours and not mine

Sorry, yes ...

Code: Select all

unzip -qc 2017-04-10-raspbian-jessie-lite.zip | sudo tee /dev/sde >/dev/null
by jahboater
Sun Apr 30, 2017 7:41 am
Forum: Troubleshooting
Topic: Why yours and not mine
Replies: 38
Views: 3630

Re: Why yours and not mine

strace on unzip shows it calls write() with a block size of 64KB which is the same as the cp command does. It should be pretty efficient.

So thanks Martin for that tip.

sudo unzip -qc 2017-04-10-raspbian-jessie-lite.zip >/dev/sde

"7z e -so" does exactly the same by the way (writes 64KB blocks).

Go to advanced search