Compiler Error Message Customization - c

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.

Related

EDK2 Error 3FFF: Sources is not a valid section Name, Fix?

This is in my Dsc file
[Sources]
UEFI.c
This is my error while compiling Error 3FFF: Sources is not a valid section Name
I tried moving My [Sources] Section checking for any errors But It still wont compile

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 setting LINKOPTS=' ' supress error message

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.

"Section type conflict" in arm embedded, what is it?

I am getting an error for this:
Can any one guide me on this? What sort of error is this. What are some generic possible errors causes for this. I am asking about Section type conflict.
What I find on Google is the people saying different things about their specific platforms, compilers.
I am using GCC, STM32F429I, and VSTAR OS (RTOS).
C:\Users\munullah\eclipseworkspace\onsvr\vstar_os\applications\sample\gen
\STM32F429I\GNU\Os_Lcfg.c:530:58: error:
Os_IsrCAT1PlatformConfig causes a section type conflict with
Os_SC1_EPSSOS_IIK_400_STM32F429I_GNU
CONSTP2CONST(Os_IsrPlatformConfigType,OS_CONST,OS_CONST) Os_IsrCAT1PlatformConfig[1];
C:\Users\munullah\eclipseworkspace\onsvr\vstar_os\applications\sample\gen\STM32F429I\GNU\Os_Lcfg.c:53:21:
note: 'Os_SC1_EPSSOS_IIK_400_STM32F429I_GNU'
was declared here
CONST(uint8,OS_VAR) Os_SC1_EPSSOS_IIK_400_STM32F429I_GNU = (uint8)0U;
^
../../BuildSystem/makefile:283: recipe for target 'objs/STM32F429I/GNU/Os_Lcfg.o' failed
make: *** [objs/STM32F429I/GNU/Os_Lcfg.o] Error 1
P.S: You may see the image properly by Right-click and then view image.

zlib on z/OS USS

Im trying to compile z/lib on z/OS USS(thats right a mainframe). ive got gmake and the c89 compiler (which im assuming is c89 standards compliant) and USS is supposed to be POSIX compliant.
But zlib seems to be tripping up on
struct internal_state FAR *state; /* not visible by applications */
with the following error(s)
c89 -O3 -DUSE_MMAP -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_SOURCE -c -o example.o example.c
ERROR CCN3277 ./zlib.h:92 Syntax error: possible missing ';' or ','?
ERROR CCN3007 ./zlib.h:92 "struct internal_state" is undefined.
ERROR CCN3166 ./zlib.h:103 Definition of function FAR requires parentheses.
ERROR CCN3276 ./zlib.h:103 Syntax error: possible missing '{'?
ERROR CCN3273 ./zlib.h:124 Missing type in declaration of gz_header.
ERROR CCN3166 ./zlib.h:126 Definition of function gz_header requires parentheses.
ERROR CCN3276 ./zlib.h:126 Syntax error: possible missing '{'?
WARNING CCN3137 ./zlib.h:1346 Declaration must declare at least one declarator, tag, or the members of an enumeration.
ERROR CCN3275 ./zlib.h:1350 Unexpected text z encountered.
ERROR CCN3282 ./zlib.h:1350 The type of the parameters must be specified in a prototype.
ERROR CCN3275 ./example.c:95 Unexpected text file encountered.
ERROR CCN3045 ./example.c:95 Undeclared identifier gzFile.
ERROR CCN3046 ./example.c:96 Syntax error.
ERROR CCN3045 ./example.c:98 Undeclared identifier file.
ERROR CCN3019 ./example.c:523 Expecting an array or a pointer to object type.
ERROR CCN3280 ./example.c:527 Function argument assignment between types "const char*" and "int" is not allowed.
CCN0793(I) Compilation failed for file ./example.c. Object file not created.
FSUM3065 The COMPILE step ended with return code 12.
FSUM3017 Could not compile example.c. Correct the errors and try again.
gmake: *** [example.o] Error 3
when i progressively take out the FAR * (i think its a far pointer but im really not that sure) the errors go away. But as this is a library, im not sure what other artifacts are going to be produced by removing this.
has anybody got any ideas?
any old mainframe heads out there?
it turns out there is a previous version of zlib that compiles on USS, version 1.1.4 or close to that. Its a back level, but i presume this works because it is before the implementation of the FAR pointer in the latest code. So atm i think ive got it to work.
thanks for all your help.
Regards
Mark.
FAR is not a C89 keyword, it is a Microsoft/Intelism and is probably #defined somewhere. If not, you need to define it as nothing:
#define FAR
However, this will probably only fix one of many problems. I would guess that the library uses some form of conditional compilation to handle things like FAR pointers - you need to read the docs to find which configuration is most suitabkle for your platform.
I'd use xlc instead of c89 since xlc is your system default compiler but you'll still probably have issues. I'd subscribe to the MVS-OE email list, the people on it are quite helpful. The link to info about the list appears to be down now so send email to
LISTSERV#VM.MARIST.EDU
with the message: INFO MVS-OE
FWIW, IBM provides a prebuilt version of zlib that includes support for the compression hardware (so-called zEDC) available on recent-vintage mainframes. See zlib for zEnterprise Data Compression

Resources