We started seeing a lot of warnings like this after upgrading to Xcode 9.3:
Macro expansion producing 'defined' has undefined behavior
Like this:
#if MIXPANEL_FLUSH_IMMEDIATELY // ==> Warning: Macro expansion producing ...
[self flush];
#endif
And this:
#if !MIXPANEL_NO_AUTOMATIC_EVENTS_SUPPORT // ==> Warning: Macro expansion producing
- (void)setValidationEnabled:(BOOL)validationEnabled {
_validationEnabled = validationEnabled;
...
}
#endif
I guess the Macro can't be nested in Xcode 9.3.
I have these warnings too.
The Macro was defined like this, which cause the warnings:
#if TARGET_OS_MAC
#define SCENEKIT_SDK_AVAILABLE defined(POP_USE_SCENEKIT)
#elif TARGET_OS_IPHONE
#define SCENEKIT_SDK_AVAILABLE defined(POP_USE_SCENEKIT)
#endif
and I fixed it like this:
#if defined(POP_USE_SCENEKIT)
# define USE_SCENEKIT 1
#else
# define USE_SCENEKIT 0
#endif
#if TARGET_OS_MAC
#define SCENEKIT_SDK_AVAILABLE USE_SCENEKIT
#elif TARGET_OS_IPHONE
#define SCENEKIT_SDK_AVAILABLE USE_SCENEKIT
#endif
I seperated the Macro "SCENEKIT_SDK_AVAILABLE" like that, and the warnings were gone.
You can try my way.
Related
I'm trying hard to get a list of style properties for a GtkWidget (GtkButton). This is my code so far:
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (int argc, char *argv[])
{
// Declare variables.
GtkWidget *btn = gtk_button_new();
guint *count = {0};
GParamSpec **list = NULL;
// Initialize gtk.
gtk_init(&argc, &argv);
// Get style properties.
list = gtk_widget_class_list_style_properties(GTK_WIDGET_CLASS(btn), count);
// Exit cleanly.
exit(EXIT_SUCCESS);
}
I get a clean compile with:
gcc -o gtk_test gtk_test.c `pkg-config --cflags --libs gtk+-3.0`
But I get the following errors when run:
(process:72182): Gtk-CRITICAL **: 10:42:23.167: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
(process:72182): Gtk-CRITICAL **: 10:42:23.167: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
(process:72182): Gtk-CRITICAL **: 10:42:23.167: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Segmentation fault
I don't think I'm doing it right, but I can't find any examples that use gtk_widget_class_list_style_properties that I understand. They ones I do find use klass and the first argument. But I can never find where klass is declared or even what it is.
Can someone please help point me in the right direction? I went to the gtk website and did a search on GTK_WIDGET_CLASS and it came back with nothing! Very frustrating to say the least.
What am I supposed to use for the GTK_WIDGET_CLASS argument that will return the style properties for a GtkButton?
I tried out your sample code. Actually, it looks like you just have the incorrect macro. Instead of:
GTK_WIDGET_CLASS(btn)
try:
GTK_WIDGET_GET_CLASS(btn)
I tried that and then received no critical messages.
Regards.
I've a Cypress BLE module and have compilation problem with IAR.
In "ezsapi.h" are defined this macros:
#ifdef __GNUC__
/* standard GNU C */
#ifdef _WIN32
/* MinGW, Cygwin, TDM-GCC, etc. */
#define __PACKDEF(STRUCTNAME, STRUCTDEF) typedef struct STRUCTDEF __attribute__((__packed__,gcc_struct)) STRUCTNAME
#else
/* generic gcc */
#define __PACKDEF(STRUCTNAME, STRUCTDEF) typedef struct STRUCTDEF __attribute__((__packed__)) STRUCTNAME
#endif
#define ALIGNED __attribute__((aligned(0x4)))
#else
/* Microsoft Visual C++ */
#define __PACKDEF(STRUCTNAME, STRUCTDEF) __pragma(pack(push, 1)) STRUCTDEF __pragma(pack(pop)) STRUCTNAME
#define ALIGNED
#endif
IAR usually use #pragma pack(push,1) and #pragma pack(pop) and I tryed to modify the macro in:
#define __PACKDEF(STRUCTNAME, STRUCTDEF) #pragma(pack(push, 1)) STRUCTDEF #pragma(pack(pop)) STRUCTNAME
With original macros the errors reported is:
ezsapi.h(694) : Error[Pe020]: identifier "pack" is undefined
ezsapi.h(694) : Error[Pe018]: expected a ")" ezsapi.h(694) :
Error[Pe079]: expected a type specifier ezsapi.h(694) : Error[Pe260]:
explicit type is missing ("int" assumed) ezsapi.h(694) : Error[Pe141]:
unnamed prototyped parameters not allowed when body is present
ezsapi.h(694) : Error[Pe130]: expected a "{"
and with my macro the errors reported is:
(69 is the line where the macro is located)
ezsapi.h(69) : Error[Pe052]: expected a macro parameter name
ezsapi.h(69) : Error[Pe052]: expected a macro parameter name
ezsapi.h(694) : Error[Pe020]: identifier "pack" is undefined
ezsapi.h(694) : Error[Pe018]: expected a ")" ezsapi.h(694) :
Error[Pe079]: expected a type specifier ezsapi.h(694) : Error[Pe260]:
explicit type is missing ("int" assumed) ezsapi.h(694) : Error[Pe141]:
unnamed prototyped parameters not allowed when body is present
ezsapi.h(694) : Error[Pe130]: expected a "{"
What's the correct formula for IAR?
What's escaping me?
Thanks.
There are two ways of solving this problem. My suggestion is that you use the __packed type attibute instead of #pragma pack() as this has a more well defined meaning. This, however, needs IAR language extensions to be switched on. If you can't enable language extensions or for some other reason need to use pack-pragma you have to use an alternative pragma syntax to be able to include it in a preprocessor macro. If you use _Pragma("pack(push,1)") and _Pragma("pack(pop)") you macro should work as expected. Definitions of PACKDEF for both alternatives are shown below:
#define PACKDEF(STRUCTNAME, STRUCTDEF) typedef __packed struct STRUCTDEF STRUCTNAME
#define PACKDEF(STRUCTNAME, STRUCTDEF) _Pragma("pack(push,1)") typedef struct STRUCTDEF STRUCTNAME _Pragma("pack(pop)")
Describe the bug: Compile error at SequoiaDB/engine/omsvc/omCommand.cpp:3765
To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/SequoiaDB/SequoiaDB.git
scons --engine
see error blow:
SequoiaDB/engine/omsvc/omCommand.cpp:3765:2: error: #endif without #if
#endif
^
SequoiaDB/engine/omsvc/omCommand.cpp:9875:2: error: #endif without #if #endif
^
SequoiaDB/engine/omsvc/omCommand.cpp:10669:2: error: #endif without #if #endif // SDB_ENTERPRISE
It looks like some mistake in the script remove code between SDB_ENTERPRISE macro before uploading to github. Now it is fixed.
enter image description here
enter image description here
When I launch the value plugin of frama-c, I get many times the same warning :
/Users/philippeantoine/.opam/4.02.3/bin/frama-c -val myprog.c
In file included from /Users/philippeantoine/.opam/4.02.3/share/frama-c/libc/stdint.h:27:
/Users/philippeantoine/.opam/4.02.3/share/frama-c/libc/features.h:63:9: warning: '__nonnull' macro redefined [-Wmacro-redefined]
#define __nonnull(args...)
^
<built-in>:286:9: note: previous definition is here
#define __nonnull _Nonnull
^
1 warning generated.
/var/folders/rj/vl86bl2n6cgdjg7m7tszcvm40000gn/T/ppannot48d4bd.c:543:9: warning: '__nonnull' macro redefined [-Wmacro-redefined]
#define __nonnull(args...)
^
/var/folders/rj/vl86bl2n6cgdjg7m7tszcvm40000gn/T/ppannot48d4bd.c:286:9: note: previous definition is here
#define __nonnull _Nonnull
^
1 warning generated.
Has anyone experience these before ?
What is the best way to avoid these and see the meaningful warnings ?
I get this with the simple code :
#include <stdlib.h>
int main (){
char * test = malloc(10);
test[0] = 'a';
}
I would like to know whether I am missing something:
//this is test.idl
typedef foo foo_t;
// end of test.idl
When I compile test.idl with the following command:
midl /W4 test.idl
I get this output
Microsoft (R) 32b/64b MIDL Compiler Version 6.00.0366
Copyright (c) Microsoft Corporation 1991-2002. All rights reserved.
Processing .\test.idl
test.idl
and I get a wrong test.h (at the bottom of this message) which has
only
typedef foo_t;
where the unknown foo type was silently discarded.
I would have expected an error message stating "foo is an unknown
type", am I wrong?
Do I need to pass any particular arguments to the MIDL command?
I got the same result with MIDL compiler version 7.00.0500
/* this ALWAYS GENERATED file contains the definitions for the
interfaces */
/* File created by MIDL compiler version 6.00.0366 */
/* at Thu Nov 13 11:47:40 2008
*/
/* Compiler settings for test.idl:
Oicf, W4, Zp8, env=Win32 (32b run)
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec
(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
//##MIDL_FILE_HEADING( )
#pragma warning( disable: 4049 ) /* more than 64k source lines */
/* verify that the <rpcndr.h> version is high enough to compile this
file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif // __RPCNDR_H_VERSION__
#ifndef __test_h__
#define __test_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
/* Forward Declarations */
#ifdef __cplusplus
extern "C"{
#endif
void * __RPC_USER MIDL_user_allocate(size_t);
void __RPC_USER MIDL_user_free( void * );
/* interface __MIDL_itf_test_0000 */
/* [local] */
typedef foo_t;
extern RPC_IF_HANDLE __MIDL_itf_test_0000_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_test_0000_v0_0_s_ifspec;
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif
I submitted the following bug to Microsoft:
MIDL does not report an error if a typedef uses an unknown type