I write C on Arduino and while pointers are near and dear to me I only take them out for beginners who may be ready for them, same as bits and bit-logic. I look at what you wrote and it's like if you don't find it, something is wrong with Arduino... where's the logic in that? Keep digging or A-s-k.
If you want to make bit patterns with spaces between, you need to interpret the text yourself or use bigger code than you need from some library you don't understand to read text and output bytes.
If that is completely beyond you then maybe you've been leaning on black boxes a bit too much to write your own state machines.
I'd say that you have solved the problem perfectly by defining your own variable mnemonics to use later in you program instead of explicitly using binary or hex representations. So you have to do it once only.
What you want requires a different compiler version as discussed. Either you wait until the Arduino environment moves to this or you just go with the flow and use comments or bitwise OR to set the bits in a readable way like it’s frequently done for registers
I’ve just noticed that under the section entitled “element definition” in the first picture, there are a number of errors in converting the hex representation to binary.
Yes, indeed! I did notice them; that is why I started this thread, asking for the nibble spaces. When I stated that it would help readability, I wasn't kidding.
Unfortunately, even following links, I do not see enough information to swap compilers, and I strongly suspect there is a reason why Arduino did not do so, as in compatibility problems.
I just want to write small compact efficient code, as best I can.
You don't have to swap compilers. You just tell the compiler to compile your code with the newer C++14 features by replacing the -std=gnu++11 flag by -std=gnu++14.
Although the information is not essential to make this small modification, it is useful for someone like yourself who desires the compiler to work differently than it does by default. You might even decide to make your own custom platform, which is not so difficult as it might sound due to the ability to reference resources from other platforms.
Arduino is very conservative about making changes like this to the boards platforms. For the target user, stability and portability is more important than having advanced shiny new language features.
On Linux, it's in ~/.arduino15/packages/arduino/hardware/avr/1.8.4/platform.txt, on Windows, probably in some (hidden?) AppData folder with a similar path.
The file is named platform.txt. You can find the location of it by doing this;
Select File > Preferences from the Arduino IDE's menus.
Check the box next to "Show verbose output during: [] compilation".
Click the OK button.
Select the board you are interested in from the Arduino IDE's Tools > Board menu. Note that this is a platform-specific modification, so it will affect only one set of boards. If you want it to apply to multiple boards then you'll need to modify each boards platform by repeating this process.
Select Sketch > Verify/Compile from the Arduino IDE's menus. It doesn't matter what sketch you compile.
Wait for the compilation to finish.
Now examine the contents of the black console pane at the bottom of the Arduino IDE window. There you will see something like this:
Using core 'arduino' from platform in folder: C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
That is the location of the platform.txt file you need to modify.
Because it would be much slower for me, and more difficult to check because I may use an odd number of bits packed into one variable, such as these three bits do....
Without knowledge of you exact field of use it’s hard to offer alternative. Are you interfacing with a device (which one) and you need to represent some binary commands or flags?
I found the setting file in: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Unfortunately, I suspect it can only understand them as enclosing delimiters.
I appears not to work.
crap:1:45: error: missing terminating ' character
const int neuron_mfst_action =0b0001'000000000000; // Outgoing Potentially Triggering Outgoing Messages
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
crap:2:1: error: expected ',' or ';' before 'const'
const int neuron_mfst_body =0b0010000000000000; // Message Parts of the System
^~~~~
exit status 1
missing terminating ' character
While that's of course a reasonable trade-off, what is the policy when it comes to C++ version upgrades? Surely we can't stay on C++11 forever, it's over 10 years old at this point, with C++14, C++17 and C++20 being released already, each of them adding features that can be really helpful for embedded programming, especially things like constexpr and consteval.
Even small improvements like being able to write 0b1111'0000 do add up. Class template argument deduction greatly simplifies user code and examples for libraries that rely on templates, some templates can be replaced by consteval functions or C++20 concepts, significantly improving error messages, and so on.
C++14 is a relatively small upgrade, and I wouldn't expect much problems. Teensy has been using C++14 for quite some time now, and ArduinoCore-mbed also uses C++14 (it uses the toolchain's default, perhaps by accident or because of Mbed requirements?).
Is this being looked into by the Arduino team? E.g. doing compilation tests for a selection of libraries and examples?
On a similar note, are there any plans to get rid of -fpermissive? I believe it is doing active harm, letting many mistakes through without errors, resulting in runtime crashes that would have been caught by the compiler otherwise.