How do I turn off warning from mpif.h with mpif90 - mpi

I'm trying to compile some code using MPI with mpif90. So I have several subroutines like :
subroutine name()
include "mpif.h"
...
and I have a huge number of warnings from this mpif.h like :
Warning: Unused parameter 'mpi_win_disp_unit' declared at (1)
mpif.h:243.27:
Included at main.f90:29:
INTEGER MPI_WIN_NULL
The problem is that I can't see the warnings that come from my actual code.
My current compiler options are :
-O3 -Wall -Wextra -Wtabs -ffixed-line-length-132
I would like to know if there is a flag that disable warnings from a specific file, or from included files.
Thank you in advance.

Related

Clang static analyzer (clazy) ignores NOLINT and similar meta instructions in Qt code

I need to switch off some warnings that the Clang static analyzer (clazy) flags in some Qt code that I work with.
Appending '// NOLINT' as a comment to code lines that get flagged by clazy does not work, apparently because Qt is transformed to C++ code before clazy gets to see it, dispensing with all comments and pragmas. Appending '// clazy:exclude...' does not work either, and likewise with
#if defined(__clang__) // if that is even the right define to look for
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-W..."
#endif
...
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
Is there any elegant way of getting rid of clazy warnings in Qt code? I would prefer it to be applicable to individual lines as opposed to disabling warnings on entire files.
You should use
<your code> // clazy:exclude=<warning>,<another warning>
For example, I get clazy-strict-iterators warning in my code.
I've added // clazy:exclude=strict-iterators in the end of line, and the warning is gone.
Note that you should not add clazy- prefix to the warning name.
Source: https://blogs.kde.org/2016/04/25/clazy-suppressing-warnings

False negative with address sanitizer?

Consider the code below. No error is shown when I compile and run it with address sanitizer. But there should be an error right i.e assigning/accessing out of bounds memory location? Why doesn't address sanitizer detect it?
int arr[30];
int main(){
arr[40] = 34;
printf(“%d”, arr[40]);
}
Thanks!
clang -fsanitize=address -fno-omit-frame-pointer test.c
./a.out
This is described by the following entry in FAQ:
Q: Why didn't ASan report an obviously invalid memory access in my code?
A1: If your errors is too obvious, compiler might have already optimized it
out by the time Asan runs.
A2: Another, C-only option is accesses to global common symbols which are
not protected by Asan (you can use -fno-common to disable generation of
common symbols and hopefully detect more bugs).

RcppZiggurat unable to compile example code

I am trying to employ the Ziggurat sampler in R, however actually wanted to use it directly in my C++ code. I installed the GSL library, RcppGSL and RcppZiggurat and using zrnorm() in R works just fine. I thought ok, lets try to compile the code sample provided in the RcppZiggurat.pdf, and go from there to implement the Ziggurat sampler directly in my C++ code... the following happens though...
From the pdf file I thought I can simply utilize:
#include <Rcpp.h>
#include <Ziggurat.h>
static Ziggurat::Ziggurat::Ziggurat zigg;
// [[Rcpp::export]]
Rcpp::NumericVector zrnorm(int n) {
Rcpp::NumericVector x(n);
for (int i=0; i<n; i++) {
x[i] = zigg.norm();
}
return x;
}
// [[Rcpp::export]]
void zsetseed(unsigned long int s) {
zigg.setSeed(s);
return;
}
Error:
official_zigg_code.cpp:2:10: fatal error: 'Ziggurat.h' file not found
#include <Ziggurat.h>
^
1 error generated.
make: *** [official_zigg_code.o] Error 1
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -
I/usr/local/include/freetype2 -I/opt/X11/include -
I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -Wall -
mtune=core2 -g -O2 -c official_zigg_code.cpp -o official_zigg_code.o
Error in Rcpp::sourceCpp("official_zigg_code.cpp") :
Error 1 occurred building shared library.
I have absolutely no clue how to proceed from here. I desperately tried to find answers on stack exchange but nothing could help me to solve this. From what I understand the RcppZiggurat package actually uses the above function so how can I fail to compile it, when I am able to use zrnorm() directly?
The error is fairly obvious:
fatal error: 'Ziggurat.h' file not found
This means that you did not tell R / the compiler about RcppZiggurat.
The fix is easy. In the case of an Rcpp-driven compilation via sourceCpp(), add
this one line
// [[Rcpp::depends(RcppZiggurat)]]
which does just that. All this is documented with Rcpp, and you are more or less expected to read at least some of its documentation.
If you want to build outside of Rcpp, you need to make sure the compiler find the header file(s). One commonly uses the -I flag for that, this is typically discussed where compiler are introduced.

ld : 0711-224 warning : Duplicate symbol (Overriding a System Call in AIX)

I read this article (http://qasim.zaidi.me/2009/05/overriding-system-call-in-aix.html;) about overriding a systemcall in aix;
I wrote two kernel extensions just like the article said "The first kernel extension would merely re-export the original system call with a different name. The second, will actually override the syscall by redefining it, and then call the original one as exported by the first module."
But there is a error when I make the second extension:
1> gcc -O2 -maix64 -ffreestanding -o my_syscall.o -c my_syscall.c -D_KERNEL
1> ld -b64 -o my_syscall my_syscall.o -e my_syscall_init -bI:/home/rabbitte/output/test_system/my_syscall.exp -bI:/usr/lib/kernex.exp -lsys -lcsys
1>ld : 0711-224 warning : Duplicate symbol: .getpid
1> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
The file "/home/rabbitte/output/test_system/my_syscall.exp" is the export file of the first extension.
I don't understand the what the "Duplicate symbol: .getpid" means. Could you tell me how to solve this problem?
Thanks very much.
The reason is that the file “kernex.exp” also include the symbol “getpid”. I should comment the getpid in file kernex.exp.
I've never done any of this, so this might not be sufficient to solve your problem, but your linker line has two -bI options. It should be -bI for the AIX kernex.exp, and -bE for your exp file according to the docs you point to.

Clang + AVR Compilation error: '=w' in asm

I got this error below and I can not find a solution. Does anybody know how
to fix this error?
rafael#ubuntu:~/avr/projeto$ clang -fsyntax-only -Os -I /usr/lib/avr/include -D__AVR_ATmega328P__ -DARDUINO=100 -Wno-ignored-attributes -Wno-attributes serial_tree.c
In file included from serial_tree.c:3:
In file included from /usr/lib/avr/include/util/delay.h:43:
/usr/lib/avr/include/util/delay_basic.h:108:5: error: invalid output
constraint
'=w' in asm
: "=w" (__count)
^
1 error generated.
util/delay.h is a Header from avr-libc, and the feature which you are using (some of the delay stuff) is using inline asm to implement it. avr-libc is written to be used with avr-gcc and uses features from avr-gcc like machine dependent constrains in inline asm. llvm does not recognize constraint "w", thus you have to use a different approach like using avr-gcc or porting that code to llvm.
avr-gcc also implements built-in function __builtin_avr_delay_cycles to implement wasting a specified number of clock cycles. If llvm is properly mimicking avr-gcc, then you can use that function as a starting point.

Resources