why setting LINKOPTS=' ' supress error message - c

I have a open source mdnsresponder c code which is compiled with bitbake. I don't face any issues when LINKOPTS is given like below
EXTRA_OEMAKE += "LINKOPTS=''"
Here nothing is set to LINKOPTS. So if I remove LINKOPTS, GCC compiler throws error message like
error: unrecognized command line option '--hash-style=gnu'. Also it throws few warning messages like -Wtype-limits, -Wunused-but-set-variable.
Is LINKOPTS in this usage required ?

Compiler provides hashstyle=gnu by default, so disabling it again in toplevel bitbake.

Related

How do I turn off warnings when compiling a kernel?

I'm trying to compile an android kernel using clang and I'm getting warnings that I don’t care about. For compilation I use the command make -j3 CC=clang O=output, so I cannot just add the -Wno-everything argument as if I were using the command clang file.c. As I understand it, I can disable some warnings by adding #pragma to the file that causes the error. But also I have one strange error that does not reference any file:
warning: unknown warning option '-Wno-vectorizer-no-neon' [-Wunknown-warning-option]
How can I turn off all warnings? Or at least this one.
PS: Sorry for my English.
The solution was to add the -Wno-everything argument to the ARCH_CPPFLAGS parameter in the Makefile.

PDCurses wont compile on windows

I am trying to compile PDCurses, but when it attempts to compile pdcscrn.c it gives the error message
../wincon/pdcscrn.c:93:5: error: unknown type name 'PCONSOLE_SCREEN_BUFFER_INFOEX'; did you mean 'PCONSOLE_SCREEN_BUFFER_INFO'?
PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PCONSOLE_SCREEN_BUFFER_INFO
../wincon/pdcscrn.c:95:5: error: unknown type name 'PCONSOLE_SCREEN_BUFFER_INFOEX'; did you mean 'PCONSOLE_SCREEN_BUFFER_INFO'?
PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PCONSOLE_SCREEN_BUFFER_INFO
../wincon/pdcscrn.c:97:8: error: unknown type name 'SetConsoleScreenBufferInfoExFn'
static SetConsoleScreenBufferInfoExFn pSetConsoleScreenBufferInfoEx = NULL;
and there are also a lot more lines, but that is the first part. I am using GCC 8.2.0, and I compiling the wincon directory because I am on windows 10. Thanks.
This is addressed in wincon/README.md:
If your build stops with errors about PCONSOLE_SCREEN_BUFFER_INFOEX,
add the parameter "INFOEX=N" to your make command line and try again.
(This will happen with older compile environments.)
BTW, you should specify the exact toolset you're using, since AFAIK there's no such thing as raw GCC for Windows -- it'll be something like MinGW or Cygwin.

What does the gcc warning "coverage_mismatch" mean?

Today I meet a Werror=Wcoverage_mismatch error when compiling some erlang/opt:
beam/beam_emu.c: In function 'erts_current_reductions':
beam/beam_emu.c:3150:1: error: the control flow of function 'erts_current_reductions' does not match its profile data (counter 'arcs') [-Werror=coverage-mismatch]
}
...
But I don't know what does it mean and google tells me nothing about this flag.
Below is gcc source code
if (entry->n_counts != n_counts)
warning_printed = warning_at(
DECL_SOURCE_LOCATION(current_function_decl), OPT_Wcoverage_mismatch,
"number of counters in profile data for function %qD "
"does not match "
"its profile data (counter %qs, expected %i and have %i)",
current_function_decl, ctr_names[counter], entry->n_counts, n_counts);
else
warning_printed = warning_at(
DECL_SOURCE_LOCATION(current_function_decl), OPT_Wcoverage_mismatch,
"the control flow of function %qD does not match "
"its profile data (counter %qs)",
current_function_decl, ctr_names[counter]);
See the GCC (9.2.0) manual on Warning options:
-Wno-coverage-mismatch
Warn if feedback profiles do not match when using the -fprofile-use option. If a source file is changed between compiling with -fprofile-generate and with -fprofile-use, the files with the profile feedback can fail to match the source file and GCC cannot use the profile feedback information. By default, this warning is enabled and is treated as an error. -Wno-coverage-mismatch can be used to disable the warning or -Wno-error=coverage-mismatch can be used to disable the error. Disabling the error for this warning can result in poorly optimized code and is useful only in the case of very minor changes such as bug fixes to an existing code-base. Completely disabling the warning is not recommended.
So, it appears that your source code has changed since the time when it was compiled, and this is likely to cause problems (hence the error message). Recompile and rerun the profiling.

Why do I get a include <windows.h> error when developing on a Windows machine in C?

I am new to C and I am trying to compile a code that uses am external library. Therefore, I am following these steps for linking a library. But at the very first one
gcc -c -Wall -Werror -fpic PICASO_SERIAL_4DLIBRARY.C
I get this
PICASO_SERIAL_4DLIBRARY.C:1:0: error: -fpic ignored for target (all code is position independent) [-Werror]
#include <windows.h>
cc1plus.exe: all warning being treated as errors
additionally undder # there is a arrow above. I tried googling it but I could only find out that this is a Linux problem and not a Windows one (I am developing on Windows now) and the I followed these steps to install gcc. an compiling other small projects work, too.
Anyone any idea, why this doesn't work?
The mention of #include <windows.h> is incidental. That just happens to be the first line of code.
The compiler tries to associate a line of code with the error to help you find the problem. But in this case the code is irrelevant. The error is in the command line and you will get a failure no matter what the code is. But because the compiler is coded to always associate a line of code with an error, it decides, arbitrarily, to point the finger at the first line of code.
Because you use -Werror, warnings are treated as errors. The compiler therefore converts a warning about an ignored option to emit position independent code into an error. The error message states this very clearly:
PICASO_SERIAL_4DLIBRARY.C:1:0: error: -fpic ignored for target (all code is position independent) [-Werror]
I suspect you glazed over when reading the error message, and turned your attention to the line of code that was highlighted. Always read error messages carefully!
To resolve the error, remove the -fpic option from your command line.
Try to compile without -fpic. This flag is inappropriate for the mingw-w64 target.

Compiler Error Message Customization

I'm trying to get error numbers or error IDs printed with the error messages from my C compiler. I am currently using GCC but if it would be easier using Clang, that would be okay too.
This is an example for an error message as I get it:
error: syntax error before '}' token
This is how I want it to be instead:
error(ERRID): syntax error before '}' token --
ERRID is a number or unique string for that error.
Is that possible with GCC or Clang? And if it is possible, how to do it?
I want this feature to make error messages searchable and identifiable for easy parsing and analyzing of errors.
Error messages are localized, you could change the error message catalog for your language to suite your needs.
Alternatively, you could modify some passes reporting the error e.g. with your plugin (or even some MELT extension).
But I am surprized you are asking, the GCC source code contains a catalog of error messages, in the gcc/po/ subdirectory of the source code.
Notice that the message catalog is using the gettext(3) machinery, so the message id is actually the English (C locale) message itself.

Resources