PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label suppress-warnings. Show all posts
Showing posts with label suppress-warnings. Show all posts

Sunday, July 17, 2022

[FIXED] Where to put the `@unchecked` to suppress "pattern match on a refinement type is unchecked"?

 July 17, 2022     annotations, scala, suppress-warnings, unchecked, warnings     No comments   

Issue

When I run the following code snippet with scala

import scala.language.reflectiveCalls

def foo(a: Option[Any]): Option[Any] = {
  a.filter {
    case x: { def bar: Boolean } => x.bar
  }
}

object Bar {
  def bar: Boolean = true
}

println(foo(Some(Bar)))

I get a warning

warning: a pattern match on a refinement type is unchecked

I've tried the following:

@unchecked case x: { def bar: Boolean } => x.bar
case (@unchecked x): { def bar: Boolean } => x.bar
case (x @unchecked): { def bar: Boolean } => x.bar
case x: @unchecked { def bar: Boolean } => x.bar
case x: { def bar: Boolean } @unchecked => x.bar
case (x: { def bar: Boolean } @unchecked) => x.bar
case x: ({ def bar: Boolean } @unchecked) => x.bar
case x: { def bar: Boolean } => (x @unchecked).bar
case x: { def bar: Boolean } => (x: { def bar: Boolean } @unchecked).bar

None of those work. This also doesn't work:

  a.filter { any => (any: @unchecked) match {
    case x: { def bar: Boolean } => x.bar
  }}

How do I suppress this warning?


Somewhat related links

This answer seems to use the @unchecked successfully inside Some(...), but I don't see how to use it with filter.


Solution

An additional pair of round parentheses around the { def ... } is required:

case x: ({ def bar: Boolean }) @unchecked => x.bar

With the additional parentheses, it compiles just fine, without any warnings.


This seems to be similar to the syntax for the "classical type-lambdas", where

({ type Lam[X] = Foo[X] })#Lam

worked, whereas

{ type Lam[X] = Foo[X] }#Lam

didn't.



Answered By - Andrey Tyukin
Answer Checked By - Pedro (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How do I prevent a Matlab test with "assertWarning" from printing warning text to the console?

 July 17, 2022     matlab, suppress-warnings, tdd, testing, warnings     No comments   

Issue

I am trying to implement a basic testing framework in Matlab as my first attempt at Test-Driven-Development. One of the tests I am trying to create is intended to verify that my function throws a specific warning under certain input conditions. My code is passing the warning-related tests as intended, however there is a huge annoyance.

When running (and passing) tests involving the "assertWarning" or "verifyWarning" functions, the warnings that are supposed to be triggered are printed to the command window and visually disrupt the printout of my test suite. Is there a way to prevent the (desired) warning from printing to the console only when being run in the tests, while still verifying that the warning is triggered? A sample test function which causes this annoying warning printout is below.

function testAcceleratorMax(testCase)
% Validate that acceleration input is forced to be <=1 and throws warning
state = [0,0,0,0]; input = [2,0];
xd = getPointMass2D_dot(state,input);
assert(isequal(xd,[0,0,1,0]),'Acceleration not ceiled correctly');
verifyWarning(testCase,@(x) getPointMass2D_dot(state,input),...
    'MATLAB:CommandedAccelOutOfBounds');
end

Solution

While it may not be the most elegant solution, I have found a much less intrusive method!

Step 1: Turn the specific warnings you are deliberately triggering to off in the test suite setup function. You could also do this and step 2 within each test function individually if needed. Even when the warning is turned off and won't print to the command window, you can access the suppressed warning using "lastwarn".

function setup(testCase)
warning('off','MATLAB:CommandedAccelOutOfBounds');
warning('off','MATLAB:CommandedSteerOutOfBounds');
end

Step 2: Turn the specific warnings back on in the test suite teardown function to reset matlab to the correct state after running the test suite.

function teardown(testCase)
warning('on','MATLAB:CommandedAccelOutOfBounds');
warning('on','MATLAB:CommandedSteerOutOfBounds');
end

Step 3: Instead of using the "verifyWarning" or "assertWarning" functions for your test, use "lastwarn" and "strcmp".

function testAcceleratorMax(testCase)
% Validate that acceleration input is forced to be <=1 and throws warning
state = [0,0,0,0]; input = [2,0];
xd = getPointMass2D_dot(state,input);
assert(isequal(xd,[0,0,1,0]),'Acceleration not ceiled correctly');
[~,warnID] = lastwarn; % Gets last warning, even though it was "off"
assert(strcmp(warnID,'MATLAB:CommandedAccelOutOfBounds'), 'Correct warning not thrown')
end


Answered By - pheidlauf
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, April 29, 2022

[FIXED] How to disable Visual Studio warnings for a specific symbol?

 April 29, 2022     c++, suppress-warnings, visual-studio, visual-studio-2015, warnings     No comments   

Issue

Is there a way in Microsoft Visual Studio 2015 Update 3 to disable a warning for a specific C++ symbol?

That is, does Microsoft Visual Studio 2015 Update 3 have a functionality similar to the one of PC-Lint documented here https://www.gimpel.com/html/techfaq.htm#q5 ?


Solution

No. The compilers typically do not have flexibility of static analysis tools. Visual studio lets to turn individual warnings on and off from command line per file or from code using pragmas per specific code lines. Docs are at Microsoft site



Answered By - Öö Tiib
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, April 28, 2022

[FIXED] What is the list of valid @SuppressWarnings warning names in Java?

 April 28, 2022     compiler-warnings, eclipse, java, suppress-warnings, warnings     No comments   

Issue

What is the list of valid @SuppressWarnings warning names in Java?

The bit that comes in between the ("") in @SuppressWarnings("").


Solution

It depends on your IDE or compiler.

Here is a list for Eclipse Galileo:

  • all to suppress all warnings
  • boxing to suppress warnings relative to boxing/unboxing operations
  • cast to suppress warnings relative to cast operations
  • dep-ann to suppress warnings relative to deprecated annotation
  • deprecation to suppress warnings relative to deprecation
  • fallthrough to suppress warnings relative to missing breaks in switch statements
  • finally to suppress warnings relative to finally block that don’t return
  • hiding to suppress warnings relative to locals that hide variable
  • incomplete-switch to suppress warnings relative to missing entries in a switch statement (enum case)
  • nls to suppress warnings relative to non-nls string literals
  • null to suppress warnings relative to null analysis
  • restriction to suppress warnings relative to usage of discouraged or forbidden references
  • serial to suppress warnings relative to missing serialVersionUID field for a serializable class
  • static-access to suppress warnings relative to incorrect static access
  • synthetic-access to suppress warnings relative to unoptimized access from inner classes
  • unchecked to suppress warnings relative to unchecked operations
  • unqualified-field-access to suppress warnings relative to field access unqualified
  • unused to suppress warnings relative to unused code

List for Indigo adds:

  • javadoc to suppress warnings relative to javadoc warnings
  • rawtypes to suppress warnings relative to usage of raw types
  • static-method to suppress warnings relative to methods that could be declared as static
  • super to suppress warnings relative to overriding a method without super invocations

List for Juno adds:

  • resource to suppress warnings relative to usage of resources of type Closeable
  • sync-override to suppress warnings because of missing synchronize when overriding a synchronized method

Kepler and Luna use the same token list as Juno (list).

Others will be similar but vary.



Answered By - cletus
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] When do I suppress warnings to source vs. Project Suppression File

 April 28, 2022     c#, suppress-warnings, warnings     No comments   

Issue

I'm working on resolving about 300 warnings and some of the warnings are unnecessary and can be suppressed. However, my question is do I suppress them in the Source - an attribute is added above the method - Or do I suppress them in the GlobalSuppressioins.cs? Is there any guidance for this, if so where?


Solution

The GlobalSuppression.cs file is for SuppressMessage attributes that cannot be placed in the source files. If a suppression can be placed in a source file it should.

Issues that cannot be placed in the source file are things like "namespaces should have at least five classes". You can't place an attribute on a namespace so it goes in the global suppressions file.



Answered By - Philip Smith
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to disable a warning which gets re-enabled in third-party code?

 April 28, 2022     c++, pragma, suppress-warnings, visual-c++, warnings     No comments   

Issue

My project requirement is to have no warnings at all, treating them as errors, but third party tools generate their own warnings whose code I cannot access.

So I have to disable specific warnings before including the third-party headers:

#pragma warning( push )
#pragma warning( disable : 4005 ) // macro redefinition
#pragma warning( disable : 4505 ) // unreferenced local function has been removed
#include <cuda_runtime_api.h>
#pragma warning( pop )

This approach sometimes works, sometimes it does not, depending on the header file.

Could it be due to the fact that considering all the warnings as errors, #pragma warning does not apply?

Or could it be that inside the included code there are #pragmas that disable mine?

How can I suppress them?

P.S.: The program is built with the /WX (treat warnings as errors) Visual Studio flag. How can I disable it in some parts of the source code, especially for third-party code I include, with the preprocessor?


Solution

From experience with very similar issues (but with the in-built Windows 'system' headers, rather than 3rd-party stuff), I have reluctantly accepted the fact that the #pragma warning (push|pop) system doesn't really work! This seems especially true when the "Enable all warnings" (/Wall) option is set, as the #pragma warning(pop) doesn't understand what 'level number' to restore.

The only workable technique I have (so far) come up with is to explicitly disable the relevant warnings before inclusion of the '3rd-Party' headers, then (again, explicitly) reset them afterwards. Here is a short extract from the "global" header (the one I use to generate the pre-compiled header) I use for building my projects:

// Turn off warnings generated by the "standard" and "MFC" header files.  *** Note: using "#pragma(push, 2) ...
// #pragma(pop)" to embrace these header files doesn't work! ***  [For some reason (possibly something weird in
// one of the headers), warnings such as 'unused parameters' and 'signed/unsigned' are not re-enabled.] ...
#pragma warning(disable:4091)   // 'typedef' ignored on left of tagGPFIDL.
#pragma warning(disable:4191)   // unsafe conversion to AFX_PMSG(W) (MMAP)
#pragma warning(disable:4239)   // Non-standard: conv. <class> to &<class>
#pragma warning(disable:4251)   // class 'XXX' needs to have dll-interface
#pragma warning(disable:4263)   // member function does not override . ...
//... and around 30 or so other, similar lines.

#include <afxwin.h>             // Minimal set of afx... (MFC) headers for the things we want to do ... (?)
#include <afxwinappex.h>        // Required for the base application class: MFC's CWinAppEx
#include <afxmdiframewndex.h>   // Base frame windows "CMDIFrameWndEx" and "CMDIChildWndEx"
#include <mmsystem.h>           // Mulitmedia APIs: allows playing of sounds in various alert message boxes
#include <MsiQuery.h>           // Required for DLL interface to the MSI installer (itself #includes msi.h)
//... and all other warning-prone headers ...

#pragma warning(default:4091)   // 'typedef' ignored on left of tagGPFIDL.
#pragma warning(default:4191)   // unsafe conversion to AFX_PMSG(W) (MMAP)
#pragma warning(default:4239)   // Non-standard: conv. <class> to &<class>
#pragma warning(default:4251)   // class 'XXX' needs to have dll-interface
#pragma warning(default:4263)   // member function does not override . ...
//... and all the others corresponding to those that were disabled

Note that, by using the #pragma warning(default:nnnn) (rather than #pragma warning(enable:nnnn)) you are resetting the warning to the project's setting, rather than blindly enabling it.

I understand that this is rather clumsy - and, almost certainly, not what you are looking or - but it does work. Also, once you have established the basic list of warnings, it's a relatively low-maintenance solution.

PS: As far as I am aware, there is no option available to the MSVC pre-processor to either detect or change the /WX (treat warnings as errors) compiler option, although you can set this for any specific warning, with #pragma warning(error:nnnn), and 'unset' it using default.


EDIT: Another possible way of disabling the following:

warning C4505: 'bar': unreferenced local function has been removed

is to actually reference the 'offending' function. But I'm not here being sarcastic - you can include a dummy static inline function that references bar (in your header) and that will silence the warning (it isn't given for functions defined as static inline). So, assuming the function bar is defined (in the 3rd-party header) like this:

static int bar(int b)
{
    return b * b;
}

but bar is never referenced in (some of) your build units, then adding this line to your 'global' header (after the inclusion of the 3rd-party header) will kill the warning (for MSVC, but not for clang-cl):

static inline int foo(int a) { return bar(a); }

Of course, if there are many such warnings, this method could become a bit cumbersome; but again, once you have the code written, it's low-maintenance.



Answered By - Adrian Mole
Answer Checked By - Timothy Miller (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How do I get warnings.warn to issue a warning and not ignore the line?

 April 28, 2022     python, python-2.7, suppress-warnings, warnings     No comments   

Issue

I'm trying to raise a DeprecationWarning, with a code snippet based on the example shown in the docs. http://docs.python.org/2/library/warnings.html#warnings.warn

Official

def deprecation(message):
    warnings.warn(message, DeprecationWarning, stacklevel=2)

Mine

import warnings
warnings.warn("This is a warnings.", DeprecationWarning, stacklevel=2) is None  # returns True

I've tried removing the stacklevel argument, setting it to negative, 0, 2 and 20000. The warning is always silently swallowed. It doesn't issue a warning or raise an exception. It just ignores the line and returns None. The docs doesn't mention the criteria for ignoring. Giving a message, makes warnings.warn correctly issue a Userwarning.

What can be causing this and how do I get warn to actually warn?


Solution

From the docs:

By default, Python installs several warning filters, which can be overridden by the command-line options passed to -W and calls to filterwarnings().

  • DeprecationWarning and PendingDeprecationWarning, and ImportWarning are ignored.
  • BytesWarning is ignored unless the -b option is given once or twice; in this case this warning is either printed (-b) or turned into an exception (-bb).

By default, DeprecationWarning is ignored. You can change the filters using the following:

warnings.simplefilter('always', DeprecationWarning)

Now your warnings should be printed:

>>> import warnings
>>> warnings.simplefilter('always', DeprecationWarning)
>>> warnings.warn('test', DeprecationWarning)
/home/guest/.env/bin/ipython:1: DeprecationWarning: test
  #!/home/guest/.env/bin/python


Answered By - Maciej Gol
Answer Checked By - Katrina (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to suppress specific warning in Tensorflow (Python)

 April 28, 2022     python, suppress-warnings, tensorflow, tensorflow2.0, warnings     No comments   

Issue

I have a model that, based on certain conditions, has some unconnected gradients, and this is exactly what I want. But Tensorflow is printing out a Warning every time it encounters the unconnected gradient.

WARNING:tensorflow:Gradients do not exist for variables

Is there any way to only suppress this specific warning? I don't want to blindly suppress all warnings since there might be unexpected (and potentially useful) warnings in the future as I'm still working on my model.


Solution

Kinda hacky way:

gradients = tape.gradient(loss, model.trainable_variables)
optimizer.apply_gradients([
    (grad, var) 
    for (grad, var) in zip(gradients, model.trainable_variables) 
    if grad is not None
])


Answered By - Jared Nielsen
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, April 27, 2022

[FIXED] How to suppress GCC warnings from library headers?

 April 27, 2022     gcc, gcc-warning, suppress-warnings, warnings     No comments   

Issue

I have a project that uses log4cxx, boost, etc. libraries whose headers generate lots of (repetitive) warnings. Is there a way to suppress warnings from library includes (i.e. #include <some-header.h>) or includes from certain paths? I'd like to use -Wall and/or -Wextra as usual on project code without relevant info being obscured. I currently use grep on make output but I'd like something better.


Solution

You may try to include library headers using -isystem instead of -I. This will make them "system headers" and GCC won't report warnings for them.



Answered By - Phi
Answer Checked By - Marilyn (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to suppress qplot's binwidth warning inside a function?

 April 27, 2022     ggplot2, r, suppress-warnings, warnings     No comments   

Issue

I am writing a function that uses qplot() to draw a histogram, for example,

> library(ggplot2)
> d=rnorm(100)
> myfun=function(x) qplot(x)

Running it gives a warning:

> myfun(d)
stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.

To suppress the warning, I tried computing the binwidth myself, but this gives an error and doesn't plot:

> myfun=function(x) print(qplot(x, binwidth=diff(range(x))/30))
> myfun(d)
Error in diff(range(x)) : object 'x' not found

I have two related questions:

  • What is going on here? Why is object 'x' not found?
  • How can I write the function so the warning is not generated?

Thanks!


Solution

I can't explain the why of this one (Hadley may swing by and do so) but using ggplot instead of qplot solves the problem:

d <- data.frame(v1 = rnorm(100))
myfun <- function(x){
    p <- ggplot(data = x, aes(x = v1)) + 
                    geom_histogram(binwidth = diff(range(x$v1))/30)
    print(p)
}

Doing it this way I get no warning message. Also, using ggplot and removing the binwidth = ... portion in geom_histogram makes the warning reappear, but then suppressMessages works as expected as well.

I suspect this has to do with namespaces or environments and when/where qplot and ggplot are evaluating arguments. But again, that's just a guess...



Answered By - joran
Answer Checked By - Senaida (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How do you suppress this warning in VS: "The type of schema applied to the document is not supported"

 April 27, 2022     suppress-warnings, visual-studio, warnings     No comments   

Issue

This morning I created an MSTest project in C#, and for one of the JSON resources, Visual Studio is showing this warning:

The type of schema applied to the document is not supported

However there's no option available in the tooltip that allows you to suppress it. So then I started looking for a specific code or something to look for in the project settings; however Microsoft's apparently full list of compiler warnings doesn't list this one, for whatever reason. Since this is a test project, I could probably just suppress all warnings across the board and be fine, but that's still not ideal.

Is there a way to suppress this one surgically, ideally in a way that applies throughout the project?


Solution

Apparently all you have to do is to close out the file. It seems to only show when the file is opened.

Perhaps a later version of Visual Studio can make this warning behave more consistently with a standard warning in VS. Really it behaves very much like a refactoring / code cleanup suggestion (which commonly has a grey, squiggly line), rather than an actual warning. It's like it's just been mislabeled in development or whatever. However the good thing is that as long as the file is closed, it doesn't pollute the build or the errors window with warning messages.



Answered By - Panzercrisis
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to ignore SettingWithCopyWarning using warnings.simplefilter()?

 April 27, 2022     pandas, python, suppress-warnings, warnings     No comments   

Issue

The question:

Can I ignore or prevent the SettingWithCopyWarning to be printed to the console using warnings.simplefilter()?

The details:

I'm running a few data cleaning routines using pandas, and those are executed in the simplest of ways using a batch file. One of the lines in my Python script triggers the SettingWithCopyWarning and is printed to the console. But it's also being echoed in the command prompt:

enter image description here

Aside from sorting out the source of the error, is there any way I can prevent the error message from being printed to the prompt like I can with FutureWarnings like warnings.simplefilter(action = "ignore", category = FutureWarning)?


Solution

Though I would strongly advise to fix the issue, it is possible to suppress the warning by importing it from pandas.core.common. I found where it's located on GitHub.

Example:

import warnings

import pandas as pd
from pandas.core.common import SettingWithCopyWarning

warnings.simplefilter(action="ignore", category=SettingWithCopyWarning)

df = pd.DataFrame(dict(A=[1, 2, 3], B=[2, 3, 4]))
df[df['A'] > 2]['B'] = 5  # No warnings for the chained assignment!


Answered By - Georgy
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to specifically suppress "Comparing identical expressions" in Eclipse-Helios JDT

 April 27, 2022     eclipse, eclipse-jdt, java, suppress-warnings, warnings     No comments   

Issue

I tried annotating the enclosing method with

    @SuppressWarnings("compareIdentical")

but this does not work (worse yet, the annotation results in its own Unsupported @SuppressWarnings("compareIdentical") warning!)

I know that I can always use

    @SuppressWarnings("all")

but that'd be more warning-suppression than I want.

FWIW, I got the "compareIdentical" string from the "Warning Options" table in http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm (a hail-mary pass, to be sure).

Thanks!


Solution

Officially, there are only 3 supported arguments to @SuppressWarnings(), as specified by the standard $9.6.4.5:

  • Unchecked warnings (§4.8, §5.1.6, §5.1.9, §8.4.1, §8.4.8.3, §15.12.4.2, §15.13.2, §15.27.3) are specified by the string "unchecked".
  • Deprecation warnings (§9.6.4.6) are specified by the string "deprecation".
  • Removal warnings (§9.6.4.6) are specified by the string "removal".

But, in small text, the standard mentions support for extra types:

For other kinds of warnings, compiler vendors should document the strings they support for @SuppressWarnings. Vendors are encouraged to cooperate to ensure that the same names work across multiple compilers.

These are supported by some compilers:

  • all to suppress all warnings
  • boxing to suppress warnings relative to boxing/unboxing operations
  • cast to suppress warnings relative to cast operations
  • dep-ann to suppress warnings relative to deprecated annotation
  • deprecation to suppress warnings relative to deprecation
  • fallthrough to suppress warnings relative to missing breaks in switch statements
  • finally to suppress warnings relative to finally block that don't return
  • hiding to suppress warnings relative to locals that hide variable
  • incomplete-switch to suppress warnings relative to missing entries in a switch statement (enum case)
  • nls to suppress warnings relative to non-nls string literals
  • null to suppress warnings relative to null analysis
  • raw to suppress warnings relative to usage of raw types
  • restriction to suppress warnings relative to usage of discouraged or forbidden references
  • serial to suppress warnings relative to missing serialVersionUID field for a serializable class
  • static-access to suppress warnings relative to incorrect static access
  • super to suppress warnings relative to overriding a method without super invocations
  • synthetic-access to suppress warnings relative to unoptimized access from inner classes
  • unchecked to suppress warnings relative to unchecked operations
  • unqualified-field-access to suppress warnings relative to field access unqualified
  • unused to suppress warnings relative to unused code and dead code

So, there is nothing which might help you.



Answered By - Martijn Courteaux
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to supress UserWarings in Openpyxl

 April 27, 2022     openpyxl, python-3.x, suppress-warnings, warnings     No comments   

Issue

I get the UserWarning 'C:\Users...\Anaconda3\lib\site-packages\openpyxl\reader\drawings.py:58: UserWarning: wmf image format is not supported so the image is being dropped warn(msg)' How can I suppress this warning message?


Solution

stovfl answered this question:

To add WMF read or write support to your application, use PIL.WmfImagePlugin.register_handler() to register a WMF handler. You have to patch openpyxl as well, dropping WMF is hardcoded, see OpenPyXL - find_images

answer



Answered By - ConSod
Answer Checked By - Katrina (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How can -Wgnu-zero-variadic-macro-arguments warning be turned off with Clang?

 April 27, 2022     clang, suppress-warnings, warnings     No comments   

Issue

Context

I read Clang's "Controlling Diagnostics via Pragmas" section about turning off particular warnings. It works well in general for all warnings except for -Wgnu-zero-variadic-macro-arguments.

The code is:

MyHeader.hpp

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"

#import "header generating -Wgnu-zero-variadic-macro-arguments warning"

#pragma clang diagnostic pop

Problem

Clang generates -Wgnu-zero-variadic-macro-arguments warnings while compiling translation units importing MyHeader.hpp.

Env

Clang Version: Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn) Target: x86_64-apple-darwin13.4.0 Thread model: posix

OS: Mac OS X 10.9.5


Solution

This seems to be working in Xcode 6.4 (6E35b). The pragma suppresses the warning now.

I have -Weverything in build settings. Without the diagnostic ignore I definitely get the warning:

Token pasting of ',' and __VA_ARGS__ is a GNU extension

Output from Terminal to match your Env section:

$ clang --version
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix

Using the following code:

#define DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#import "Macros.h"
#pragma clang diagnostic pop

In which Macros.h contains:

#ifdef DEBUG
#define AssLog(condition, message, ...) NSAssert(condition, message, ##__VA_ARGS__)
#else
#define AssLog(condition, message, ...) if (!condition) NSLog((@"%@ [Line %d] " message), [NSString stringWithUTF8String:__PRETTY_FUNCTION__], __LINE__, ##__VA_ARGS__)
#endif


Answered By - Jeff
Answer Checked By - Marie Seifert (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing