In Gtk3 development am using gtkcomboboxtext widget in glade i selected active item as zero but its not working..So i wrote this line
gtk_combo_box_set_active (combo,0);
in my code.This works but its throwing some warning while compiling how can i do this in a clean way?
The warning shown is this
usr/include/gtk-3.0/gtk/gtkcombobox.h:99:15: note: expected ‘struct GtkComboBox *’ but argument is of type ‘struct GtkComboBoxText *’
test.c:247:13: warning: passing argument 1 of ‘gtk_combo_box_set_active’ from incompatible pointer type [enabled by default]
In file included from /usr/include/gtk-3.0/gtk/gtkappchooserbutton.h:29:0,
from /usr/include/gtk-3.0/gtk/gtk.h:45,
from test.c:1:
Excerpt from the docs gtk_combo_box_new (it's the same for GtkBuilder created widgets, they are all cast to GtkWidget, but read on):
gtk_combo_box_new ()
GtkWidget * gtk_combo_box_new (void);
Creates a new empty GtkComboBox.
Returns :
A new GtkComboBox.
Since 2.4
and another gtk_combo_box_set_active
gtk_combo_box_set_active ()
void gtk_combo_box_set_active (GtkComboBox *combo_box,
gint index_);
Sets the active item of combo_box to be the item at index.
combo_box :
A GtkComboBox
index_ :
An index in the model passed during construction, or -1 to have no active item
Since 2.4
The issue is obviously that the returnvalue of gtk_combo_box_new is a GtkComboBox already cast to GtkWidget (convenience) whereas gtk_combo_box_set_active expects a GtkCombobox.
To silence and fix the warning use either the cast macro GTK_COMBO_BOX (combo) or (GtkComboBox*)combo instead of bare combo.
Next time have a look at tha API docs first (web or via devhelp).
Related
Using the LLVM 8.0.1 library, I try to create the debug info for a function with the following code:
DIFile *Unit = DebugBuilder->createFile(CompileUnit->getFilename(), CompileUnit->getDirectory());
DIScope *FContext(Unit);
DISubprogram *SP = DebugBuilder->createFunction(
FContext, def->Name, def->Name, Unit, LineNo,
CreateFunctionType(ft, CompileUnit->getFile()), 0);
func->setSubprogram(SP);
This, however, results in IR like the following:
define i32 #main(i32 %y) !dbg !3 {
entry:
ret i32 2
}
; ...
!3 = !DISubprogram(name: "main", linkageName: "main", scope: !2, file: !2, type: !4, spFlags: 0, retainedNodes: !7)
; ...
!7 = <temporary!> !{}
Which, upon calling DebugBuilder->finalize(), throws Assertion failed: !N->isTemporary() && "Expected all forward declarations to be resolved"
I have not found a description of the retainedNodes field in the official reference nor other tutorials, and web searches only lead to uncommented sections of the LLVM source. What is the meaning or purpose of this field? How is a temporary node created there?
I found this solved by adding, before generating the DebugBuilder,
TheModule->addModuleFlag(llvm::Module::Warning, "CodeView", 1);
... as explained apparently nowhere in the official documentation.
I had the same problem with the LLVM C API (using inkwell-rs as a wrapper). I fixed this problem by invoking LLVMDIBuilderCreateFunction with IsDefinition = true and IsLocalToUnit = true. This keeps the retainedNodes metadata node, but its value is empty metadata (!{}) instead of a temporary.
I solved a similar problem by finalizing the subprogram explicitly with finalizeSubprogram.
DebugBuilder->finalizeSubprogram(SP);
This seems to resolve the temporary, but I still got some warnings, when compiling the generated IR.
If you make the function a definition by adding the DISubprogram::SPFlagDefinition flag to DebugBuilder->createFunction call, retainedNodes will be set to an empty node instead of a temporary.
I get unexpected results from the following code snippet using the eclipse ide:
class Example(String s = "init") {
shared String a() => "Func 1";
shared String b = "Attr 1";
shared String c(Integer i) { return "Func 2"; }
}
shared
void run() {
// 1.
print("getAttributes: " + `Example`.getAttributes().string);
print("getMethods: " + `Example`.getMethods().string);
// prints: []
// i.e. doesnt print any attribute or method
// 2.
value e = Example()
type(e); // error
e.type(); // error, should be replaced by the ide with the above version.
}
ad 1.) I get as a result:
getAttributes: []
getMethods: []
where I expected lists containing attributes or methods.
ad 2.) The doc says:
"The type() function will return the closed type of the given instance, which can only be a ClassModel since only classes can be instantiated.
..."
But I cant find the type() function and others related to meta programming, i.e. I dont get a tooltip, but instead I get a runtime (!) error:
Exception in thread "main" com.redhat.ceylon.compiler.java.language.UnresolvedCompilationError: method or attribute does not exist: 'type' in type 'Example'
So, where is the equivalent to the backticks `Example`.... as a function ?
`Example`.getAttributes() returns an empty list because getAttributes takes three type arguments: Container, Get, Set. When called as getAttributes(), the typechecker tries to infer them, but since there’s no information (no arguments with the appropriate type), the inferred type argument is Nothing. Since Nothing is not a container of any of the class’ members, the resulting list is empty. Use getAttributes<>() instead to use the default type arguments, or specify them explicitly (e. g. getAttributes<Example>()). Same thing with getMethods(). Try online
The type function is in ceylon.language.meta and needs to be imported: import ceylon.language.meta { type }. Once you do that (and remove the e.type() line), the compilation error will go away.
If you directly want a meta object of the function, you can write `Example.a`.
I am trying to call Advapi32.LsaOpenPolicy() from basic MSI InstallShield code. I've successfully called other avdapi32.dll methods; But LsaOPenPolicy is throwing a mismatched type error.
My prototype is:
prototype INT Advapi32.LsaOpenPolicy(POINTER, POINTER, INT, POINTER);
The windows definition is:
NTSTATUS LsaOpenPolicy(
_In_ PLSA_UNICODE_STRING SystemName,
_In_ PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
_In_ ACCESS_MASK DesiredAccess,
_Inout_ PLSA_HANDLE PolicyHandle
);
I've noted in C++ samples that the ObjectAttriibute structure is zeroed out. So I do something similar here in the InstallShield code -- pArray points to the array contents.
for i = 0 to 11
array(i) = 0;
endfor;
array(0) = 24;
// current error is 80020005 type mismatch.
try
i = POLICY_CREATE_ACCOUNT | POLICY_LOOKUP_NAMES;
pArray = array;
pPolicy = NULL;
nvOSResult = LsaOpenPolicy(NULL, pArray, i, pPolicy);
catch
Sprintf(errString, "0x%08x", Err.Number);
_Logger(hMSI, methodName, "LsaOpenPolicy Exception "+errString, INFORMATION, FALSE);
nvOSResult = Err.Number;
endcatch;
There not much other information I can find other than the 80020005 error thrown; I've tried a few different argument constructions, but I can't get past this.
I've posted this in an flexera and microsoft forum -- but I have gotten no traction there. (references for posterity: flexera-link, microsoft-link)
Any help or suggestions are welcome!
The answer to this question was to actually work-around the interface between installshield and the system DLLs by moving all the workings into a C++ DLL. As installation got more complex, I ended up with two separate DLL functions, one executed at dialog (non-admin) mode and one at deferred execution (admin) mode.
In order to pass information I used the MsiGetProperty() API using MSI properties for both input and output variables.
Note that for deferred execution, I needed a CAD function on the installshield side to marshal data into the custom action data location, and on the DLL side extract the data, again by using MsiGetProperty() but getting the "CustomActionData" property and then parse the resulting string which contained the marshaled data.
I am getting VC++ 2010 C2061 error on line:
#include "queryevaluator_p.h"
class QueryEvaluator {
public:
vector<AttrValue>* getCandidateList(QueryClause cl, int pos, ResultSet *computedRes);
...
Error 41 error C2061: syntax error : identifier 'ResultSet' h:\dropbox\sch\cs3202\code\source\includes\queryevaluator.h 40
ResultSet is a struct defined in "queryevaluator_p.h"
struct ResultSet{ //a set of result
bool valid;
vector<ResultRow> rows;
};
Whats wrong here? ResultSet can be used elsewhere
Maybe you have circular includes (queryevaluator_p.h includes the main header again) causing confusion. Depending on the exact setup this can lead to such an effect, because one of the files will have to be compiled first.
The solution would be to resolve the circular dependency by using a forward declaration instead of an include in one place. For example you could forward declare struct ResultSet instead of including the queryevaluator_p.h header.
How to check whether a given point is contained in a rectangle using the contains() function in Rect_ construct... Please give me the exact function and its parameters. Like when I type this
Point b(2,2);
Rect a(10,10,50,50);
cout<< Rect_::contains(b);
There is a compile error saying 1>c:\users\kaushal\documents\visual studio 2008\projects\test1\test1.cpp(23) : error C2352: 'cv::Rect_<_Tp>::contains' : illegal call of non-static member function
1>c:\opencv2.1\include\opencv\cxcore.hpp(385) : see declaration of 'cv::Rect_<_Tp>::contains'
You want to use the instance of a defining the area to run the method for deciding a contains b. The method contains is not static, therefor you cannot call it on the class Rect.
Point b(2,2);
Rect a(10,10,50,50);
cout<< Rect_::contains(b); // error here - contains is not static so can't be called on class
cout<< a.contains(b); // this is what you want - use instance with knowledge of rect