When a system call fails, it usually returns -1 and sets the variable
errno to a value describing what went wrong. (These values can be
found in <errno.h>.) Many library functions do likewise. The
function perror() serves to translate this error code into human-
readable form. Note that errno is undefined after a successful
system call or library function call: this call may well change this
variable, even though it succeeds, for example because it internally
used some other library function that failed. Thus, if a failing
call is not immediately followed by a call to perror(), the value of
errno should be saved.
And I am not the only one using perror wrong. Take this gem
I have commented out here just to show the original code.
This "example" shows why some coders do not check the call result.
I have moved the code to run on RPi ARM and have NO ISSUES!
I shall go ahead and finish my experiment passing data using bluetooth on SAME hardware,
Perhaps when I get it fully working it will be easier to find why it fails on X86.
Thanks four your help.
I do what I can but I haven`t found exactly what I was looking for, though that`s only because I wasn`t looking for the right thing maybe. I know there is tons of material out there but I don`t trust them unless I`m specifically pointed to a resource by someone.
Richard thanks for your useful feedback.
Today I tried to run a python script but it needed python 3.7. I did not have that in the Msys32 setup I was using. After some searching I tried to put the Msys32 configuration up to date but it completely failed and became totally inoperable. It was not even possible to start the Mingw32 shell in it any more.
I Also had an Msys64 setup available and tried to update that one and it worked perfectly. I installed python 18.104.22.168 and was able to run the python script from within the updated Mingw64 shell. The Msys64 setup also contains a Mingw32 shell which runs equally well.
So far so good but now I have a completely different problem: whenever I try to run the make command for my project ( either manually in the Mingw32 or Mingw64 shell or from Visual studio code ) I get a really odd error message:
mkdir -p build/./main/
The syntax of the command is incorrect.
make: *** [build/./main/hello_world_main.c.o] Error 1
It is the mkdir -p build/./main/ which appears to be the culprit but strangely enough that used to work perfectly and when I type the exact same command from within either the Mingw32 or Mingw64 shell it executes perfectly without the slightest trace of an error message.
For completeness I have included the Makefile content below but this has really thrown a spanner in the works. Does anyone have an idea as to what may be the cause of this?
Just took a look and it seems that the commands make will process are at or near the top of the file, and then the rules that make used follow e.g.
$ make -p hello > make.out 2>&1
$ head -20 make.out
cc hello.c -o hello
# GNU Make 4.2.1
# Built for arm-unknown-linux-gnueabihf
# Copyright (C) 1988-2016 Free Software Foundation, Inc.
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.
# Make data base, printed on Tue Feb 4 12:02:00 2020
<D = $(patsubst %/,%,$(dir $<))
?F = $(notdir $?)
.SHELLFLAGS := -c
XDG_SESSION_CLASS = user
Trying to figure out the rules that make used to generate the commands can sometimes be challenging, though.
It is one of the results I got for this google search: temporary batch file created by make does not work msys2
The reason for that search is that Richard suggested there is an option to ensure that make's output becomes a lot more verbose. The option is -d and it produces a lot more output if you use it.
In that output I noticed that make created a temporary batch file and tried to execute it but failed.
The content of that batch file was this: mkdir -p build/./main/, exactly the error that a standard make call produced.
So: apparently make could not execute the batch files it creates itself so I googled so as to know why and found the result mentioned above.
It suggested I was using the wrong version of make to try and build my application and as it turns out that was exactly what was wrong.
The make I was using was the one that was installed with the toolchain and when you type make -v it reports:
GNU Make 3.82
Built for i686-pc-mingw32
I then used pacman -S make to install the proper make version and that one reports this:
GNU Make 4.3
Built for x86_64-pc-msys
End result: when you run things in the latest mingw64 or mingw32 shell it requires the newer make version built for msys instead of the earlier version which did work in the older version of mingw32 shell. When I use the later version of make Built for x86_64-pc-msys it works like a charm again.
Last Visit: 31-Dec-99 18:00 Last Update: 25-Sep-23 4:41