Search Results

Search found 976 results on 40 pages for 'typedef'.

Page 21/40 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • C++ Ambiguous call to Overloaded Function (const variety)

    - by Joe
    After researching this online, I've only found solutions that don't apply to my problem, so please bear with me. Code snippet: typedef my_map_t<int const *, float> _test; my_map_t::const_iterator not_found = my_map_t::end(); if (_test.find(&iKeyValue) == not_found) { _test[iKeyValue] = 4 + 5; // not the actual code, but here for simplicity } The compiler complains that there's an ambiguous call to my_map_t::end(). This makes sense, because the only difference is the return type. Output: error C2668: 'std::_Tree<_Traits>::end' : ambiguous call to overloaded function Normally you can disambiguate the call by casting the parameters, but end() has no parameters. Any ideas?

    Read the article

  • PostgreSQL - CREATE INDEX

    - by mocopera
    Hi! I'm working with PostgreSQL to create some data types written in C. For example, I have: typedef struct Point3D { char id[50]; double x; double y; double z; } Point3D; The input and output functions are working properly. But the problem is the following: Every id of Point3D must be unique (and can be NULL), so I have decided to create an unique index on this field id, but is that possible? I'm thinking in something like this: create unique index test_point3d_idx on test_point3d (( getID(columname) )); where getID returns the field ID of columname. But I need to implement getID and I am really blocked. Any advice?

    Read the article

  • Possible: Set Operations on Disparate Maps with Same Key Type?

    - by Catskul
    Let's say I have two maps: typedef int Id; std::map<Id, std::string> idToStringMap; std::map<Id, double> idToDoubleMap; And let's say I would like to do a set operation on the keys of the two maps. Is there an easier way to do this than to create a custom "inserter" iterator? such that I could do something like: std::set<Id> resultSet; set_difference( idToStringMap.begin(), idToStringMap.end(), idToDoubleMap.begin(), idToDoubleMap.end(), resultSet.begin() ); My experimentation results imply that it will be necessary to create a custom inserter and perhaps a custom key comparer to do this, but I want for some insight/shortcut before doing so.

    Read the article

  • 0 not a valid FILE* when provided as a template argument

    - by Seva Alekseyev
    The following code #include <stdio.h> template <typename T, T v> class Tem { T t; Tem() { t = v; } }; typedef Tem<FILE*,NULL> TemFile; when compiled in a .mm file (Objective C++) by Xcode on MacOS X, throws the following error: error: could not convert template argument '0' to 'FILE*'. What's going on, please? The code in question compiled fine under MSVC. Since when is the 0 constant not a valid pointer to anything? Is this an artifact of Objective C++ (as opposed to vanilla C++)?

    Read the article

  • what is the mistake in my code

    - by Solitaire
    class myslot { public: Q_OBJECT myslot() { } ~myslot() { } typedef enum Emycars{volvo,benz,tata}cars; public slots: void hellowslot(myslot::cars); }; void myslot::hellowslot(myslot::cars cars1) { } class mysignal { public: Q_OBJECT public: mysignal(myslot *ourslot) { bool val = QObject::connect(this,SIGNAL(hellowsignal(myslot::Emycars)),ourslot,SLOT(hellowslot(myslot::Emycars))); } ~mysignal() { } signals: void hellowsignal(myslot::Emycars); }; int main(int argc, char *argv[]) { QApplication a(argc, argv); myslot slot; mysignal sig(&slot); // DeleteNow w; // w.showMaximized(); return a.exec(); } what is the mistake in mycode, the way which i have written connect for the function which recive enum is right or not? please let me know where i am wrong.

    Read the article

  • Objective-C : enum like Java (int values and many others for each enum)

    - by Oliver
    In Java, you can make an enum having multiples values. In objective-C, this cannot be done easily. I've read many pages about this but I didn't found anything satisfying that would allow me to use enums by a simple way and to keep the enum declaration and their different values in the same file. I would like to write something like this in a enums.h : // ======================================== typedef enum {eRED, eGREEN, eBLUE} ColorEnum; int colorValues[] = { 0xFF0000, 0x00FF00, 0x0000FF }; NSArray *colorNames = [NSArray arrayWithObjects:@"Red color", @"light green", @"Deep blue", nil]; // ======================================== and be able to use thoses global variables to manage my stuff anywhere like : int color = colorValues[eRED]; But I don't know how to write this. I have compile errors like "ColorValues" is defines many times. Or if I just use "static", I have many "ColorValues" not used in .m file... Could you help me ?

    Read the article

  • wrapp a function whose parameters are out type pointer to structure using swig

    - by pierr
    I have following function : typedef struct tagT{ int a ; int b ; }Point; int lib_a_f_5(Point *out_t) { out_t->a = 20; out_t->b = 30; return 0; } How should I direct the SWIG to generate the correct code for ruby (or lua)? When putting following statement to the interface file : %apply SWIGTYPE Point* {Point *out_t}; I got a warning : liba.i:7: Warning(453): Can't apply (Point *OUTPUT). No typemaps are defined. Did i need to write a typemap? How should I do it?

    Read the article

  • Port C's fread(&struct,....) to Python

    - by user287669
    Hey, I'm really struggling with this one. I'am trying to port a small piece of someone else's code to Python and this is what I have: typedef struct { uint8_t Y[LUMA_HEIGHT][LUMA_WIDTH]; uint8_t Cb[CHROMA_HEIGHT][CHROMA_WIDTH]; uint8_t Cr[CHROMA_HEIGHT][CHROMA_WIDTH]; } __attribute__((__packed__)) frame_t; frame_t frame; while (! feof(stdin)) { fread(&frame, 1, sizeof(frame), stdin); // DO SOME STUFF } Later I need to access the data like so: frame.Y[x][y] So I made a Class 'frame' in Python and inserted the corresponding variables(frame.Y, frame.Cb, frame.Cr). I have tried to sequentially map the data from Y[0][0] to Cr[MAX][MAX], even printed out the C struct in action but didn't manage to wrap my head around the method used to put the data in there. I've been struggling overnight with this and have to get back to the army tonight, so any immediate help is very welcome and appreciated. Thanks

    Read the article

  • Using a boost::fusion::map in boost::spirit::karma

    - by user1097105
    I am using boost spirit to parse some text files into a data structure and now I am beginning to generate text from this data structure (using spirit karma). One attempt at a data structure is a boost::fusion::map (as suggested in an answer to this question). But although I can use boost::spirit::qi::parse() and get data in it easily, when I tried to generate text from it using karma, I failed. Below is my attempt (look especially at the "map_data" type). After some reading and playing around with other fusion types, I found boost::fusion::vector and BOOST_FUSION_DEFINE_ASSOC_STRUCT. I succeeded to generate output with both of them, but they don't seem ideal: in vector you cannot access a member using a name (it is like a tuple) -- and in the other solution, I don't think I need both ways (member name and key type) to access the members. #include <iostream> #include <string> #include <boost/spirit/include/karma.hpp> #include <boost/fusion/include/map.hpp> #include <boost/fusion/include/make_map.hpp> #include <boost/fusion/include/vector.hpp> #include <boost/fusion/include/as_vector.hpp> #include <boost/fusion/include/transform.hpp> struct sb_key; struct id_key; using boost::fusion::pair; typedef boost::fusion::map < pair<sb_key, int> , pair<id_key, unsigned long> > map_data; typedef boost::fusion::vector < int, unsigned long > vector_data; #include <boost/fusion/include/define_assoc_struct.hpp> BOOST_FUSION_DEFINE_ASSOC_STRUCT( (), assocstruct_data, (int, a, sb_key) (unsigned long, b, id_key)) namespace karma = boost::spirit::karma; template <typename X> std::string to_string ( const X& data ) { std::string generated; std::back_insert_iterator<std::string> sink(generated); karma::generate_delimited ( sink, karma::int_ << karma::ulong_, karma::space, data ); return generated; } int main() { map_data d1(boost::fusion::make_map<sb_key, id_key>(234, 35314988526ul)); vector_data d2(boost::fusion::make_vector(234, 35314988526ul)); assocstruct_data d3(234,35314988526ul); std::cout << "map_data as_vector: " << boost::fusion::as_vector(d1) << std::endl; //std::cout << "map_data to_string: " << to_string(d1) << std::endl; //*FAIL No 1* std::cout << "at_key (sb_key): " << boost::fusion::at_key<sb_key>(d1) << boost::fusion::at_c<0>(d1) << std::endl << std::endl; std::cout << "vector_data: " << d2 << std::endl; std::cout << "vector_data to_string: " << to_string(d2) << std::endl << std::endl; std::cout << "assoc_struct as_vector: " << boost::fusion::as_vector(d3) << std::endl; std::cout << "assoc_struct to_string: " << to_string(d3) << std::endl; std::cout << "at_key (sb_key): " << boost::fusion::at_key<sb_key>(d3) << d3.a << boost::fusion::at_c<0>(d3) << std::endl; return 0; } Including the commented line gives lots of pages of compilation errors, among which notably something like: no known conversion for argument 1 from ‘boost::fusion::pair’ to ‘double’ no known conversion for argument 1 from ‘boost::fusion::pair’ to ‘float’ Might it be that to_string needs the values of the map_data, and not the pairs? Though I am not good with templates, I tried to get a vector from a map using transform in the following way template <typename P> struct take_second { typename P::second_type operator() (P p) { return p.second; } }; // ... inside main() pair <char, int> ff(32); std::cout << "take_second (expect 32): " << take_second<pair<char,int>>()(ff) << std::endl; std::cout << "transform map_data and to_string: " << to_string(boost::fusion::transform(d1, take_second<>())); //*FAIL No 2* But I don't know what types am I supposed to give when instantiating take_second and anyway I think there must be an easier way to get (iterate over) the values of a map (is there?) If you answer this question, please also give your opinion on whether using an ASSOC_STRUCT or a map is better.

    Read the article

  • iPhone switch statement using enum

    - by Boris
    I have defined an enum in a header file of a class : typedef enum{ RED = 0, BLUE, Green } Colors; - (void) switchTest:(Colors)testColor; and in the implementation file I have : - (void) switchTest:(Colors)testColor{ if(testColor == RED){ NSLog(@"Red selected"); } switch(testColor){ case RED: NSLog(@"Red selected again !"); break; default: NSLog(@"default selected"); break; } } My code compiles correctly without warrnings. When calling the switchTest method with RED, the output is : "Red selected" but once the first line of the switch runs, the application quits unexpectedly and without warrnings/errors. I don't mind using if/else syntax but I would like to understand my mistake.

    Read the article

  • const TypedeffedIntPointer not equal to const int *

    - by dirk
    I have the following C++ code: typedef int* IntPtr; const int* cip = new int; const IntPtr ctip4 = cip; I compile this with Visual Studio 2008 and get the following error: error C2440: 'initializing' : cannot convert from 'const int *' to 'const IntPtr' Clearly my understanding of typedefs is not what is should be. The reason I'm asking, I'm storing a pointer type in a STL map. I have a function that returns a const pointer which I would like to use to search in the map (using map::find(const key_type&). Since const MyType* and const map<MyType*, somedata>::key_type is incompatible, I'm having problems. Regards Dirk

    Read the article

  • WITH_OBJECT_HEADERS enabled GC from Dalvik?

    - by Wonil
    Hello, As I know Dalvik VM does not support generational GC as default. But, I found "WITH_OBJECT_HEADERS" compilation flag which could be related with generational GC from HeapInternal.h file. typedef struct DvmHeapChunk { #if WITH_OBJECT_HEADERS u4 header; const Object *parent; const Object *parentOld; const Object *markFinger; const Object *markFingerOld; u2 birthGeneration; u2 markCount; u2 scanCount; u2 oldMarkGeneration; u2 markGeneration; u2 oldScanGeneration; u2 scanGeneration; #endif Does anyone try to build Dalvik with this option enabled? Do you know anything about generational GC support from Dalvik? Regards, Wonil.

    Read the article

  • System::IDisposable woes

    - by shadeMe
    public ref class ScriptEditor : public Form { public: typedef map<UInt32, ScriptEditor^> AlMap; static AlMap AllocationMap; Form^ EditorForm; RichTextBox^ EditorBox; StatusBar^ EditorStatusBar; StatusBarPanel^ StatusBarLineNo; void Destroy() { EditorForm->Close(); } ScriptEditor(unsigned int PosX, unsigned int PosY); }; The above code throws an Error C2039: '{dtor}' : is not a member of 'System::IDisposable'. I'm quite lost after having looked into articles that explain how the CLR manages memory. Any advice on getting rid of it would be appreciated. My first dabble in C+++/CLI isn't going too well.

    Read the article

  • llvm clang struct creating functions on the fly

    - by anon
    I'm using LLVM-clang on Linux. Suppose in foo.cpp I have: struct Foo { int x, y; }; How can I create a function "magic" such that: typedef (Foo) SomeFunc(Foo a, Foo b); SomeFunc func = magic("struct Foo { int x, y; };"); so that: func(SomeFunc a, SomeFunc b); // returns a.x + b.y; ? Note: So basically, "magic" needs to take a char*, have LLVM parse it to get how C++ lays out the struct, then create a function on the fly that returns a.x + b.y; Thanks!

    Read the article

  • Exception on malloc for a structure in C

    - by Derek
    Hi all, I have a structure defined like so: typedef struct { int n; int *n_p; void **list_pp; size_t rec_size; int n_buffs; size_t buff_size } fl_hdr_type; and in my code I Have a function for initlialization that has the following fl_hdr_type *fl_hdr; fl_hdr = malloc(sizeof(fl_hdr_type) + (buff_size_n * rec_size_n)); where those buffer size are passed in to the function to allow space for the buffers as well. The size is pretty small typically..100*50 or something like that..plenty of memory on this system to allocate it. Any ideas why this fails?

    Read the article

  • Marshal managed string[] to unmanaged char**

    - by Vince
    This is my c++ struct (Use Multi-Byte Character Set) typedef struct hookCONFIG { int threadId; HWND destination; const char** gameApps; const char** profilePaths; } HOOKCONFIG; And .Net struct [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct HOOKCONFIG { public int threadId; public IntPtr destination; // MarshalAs? public string[] gameApps; // MarshalAs? public string[] profilePaths; } I got some problem that how do I marshal the string array? When I access the struct variable "profilePaths" in C++ I got an error like this: An unhandled exception of type 'System.AccessViolationException' occurred in App.exe Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. MessageBox(0, cfg.profilePaths[0], "Title", MB_OK); // error ... Orz

    Read the article

  • Data Types and Structs

    - by dubya
    I'm reviewing for a test, and I am stumped by this question. Consider the following declarations: enum CategoryType {HUMANITIES, SOCIALSCIENCE, NATURALSCIENCE}; const int NUMCOURSES = 100; struct CourseRec { string courseName; int courseNum; CategoryType courseCategory; }; typedef CourseRec CourseList [NUMCOURSES]; CourseList courses; int index1, index2; What is the data type of the expression courses[index1] .courseName[index2] ? (a) CourseList (b) CourseRec (c) string (d) char (e) none; the expression is syntactically invalid I thought that the answer would be string, since courseName is a string, or maybe even CourseRec, since it is in the struct, but the answer is (d)char. Why is this a char data type? Any help is greatly appreciated.

    Read the article

  • Call an IOUSBDeviceInterface function on an obj-c object instead of a C structure

    - by b1onic
    Let's say I want to close an USB device. Here is a C structure representing the USB device: struct __USBDevice { uint16_t idProduct; io_service_t usbService; IOUSBDeviceInterface **deviceHandle; IOUSBInterfaceInterface **interfaceHandle; Boolean open; }; typedef struct __USBDevice *USBDeviceRef; Here is the code to close the device: // device is a USBDeviceRef structure // USBDeviceClose is a function member of IOUSBDeviceInterface C Pseudoclass (*device->deviceHandle)->USBDeviceClose(device->deviceHandle); Now imagine that the device properties are declared in an obj-c class @interface Device : NSObject { NSNumber idProduct io_service_t usbService; IOUSBDeviceInterface **deviceHandle; IOUSBInterfaceInterface **interfaceHandle; BOOL open; } @end How would I do to call USBDeviceClose() ?

    Read the article

  • global std::unordered_map com server init problems

    - by PrettyFlower
    I want to have a static global std::unordered_map in the cpp of my entry point for my COM server. relevant header code: typedef unordered_map<HWND,IMyInterface*> MyMapType; relevant body: static MyMapType MyMap; void MyFunction(HWND hWnd, IMyInterface* pObj){ MyMap[HWND] = pObj; } HINSTANCE g_hInstModule = NULL; BOOL WINAPI DllMain ( __in HINSTANCE hInstDLL, __in DWORD fdwReason, __in LPVOID lpvReserved ) { if( fdwReason == DLL_PROCESS_ATTACH ) { g_hInstModule = hInstDLL; return true; } else if( fdwReason == DLL_PROCESS_DETACH ) { return true; } return false; } MyCoClass::MyCoClass() { DRM_Refcount = 1; } HRESULT STDMETHODCALLTYPE MyCoClass::InitMyCoClass() { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); //replace with make window code MyFunction(hWnd,ISomeInterface); return S_OK; } The only way I can get this to work is be making a map_type pointer and creating an instance of map_type on the heap and pointing at it with the global pointer. :/ WHY?

    Read the article

  • Boost::Container::Vector with Enum Template Argument - Not Legal Base Class

    - by CuppM
    Hi, I'm using Visual Studio 2008 with the Boost v1.42.0 library. If I use an enum as the template argument, I get a compile error when adding a value using push_back(). The compiler error is: 'T': is not a legal base class and the location of the error is move.hpp line 79. #include <boost/interprocess/containers/vector.hpp> class Test { public: enum Types { Unknown = 0, First = 1, Second = 2, Third = 3 }; typedef boost::container::vector<Types> TypesVector; }; int main() { Test::TypesVector o; o.push_back(Test::First); return 0; } If I use a std::vector instead it works. And if I resize the Boost version first and then set the values using the [] operator it also works. Is there some way to make this work using push_back()?

    Read the article

  • Calling a C function in a DLL with enum parameters from Delphi

    - by dommer
    I have a third-party (Win32) DLL, written in C, that exposes the following interface: DLL_EXPORT typedef enum { DEVICE_PCI = 1, DEVICE_USB = 2 } DeviceType; DLL_EXPORT int DeviceStatus(DeviceType kind); I wish to call it from Delphi. How do I get access to the DeviceType constants in my Delphi code? Or, if I should just use the values 1 and 2 directly, what Delphi type should I use for the "DeviceType kind" parameters? Integer? Word?

    Read the article

  • Compiler error when casting to function pointer

    - by detly
    I'm writing a bootloader for the PIC32MX, using HiTech's PICC32 compiler (similar to C90). At some point I need to jump to the real main routine, so somewhere in the bootloader I have void (*user_main) (void); user_main = (void (*) (void)) 0x9D003000; user_main(); (Note that in the actual code, the function signature is typedef'd and the address is a macro.) I would rather calculate that (virtual) address from the physical address, and have something like: void (*user_main) (void); user_main = (void (*) (void)) (0x1D003000 | 0x80000000); user_main(); ...but when I try that I get a compiler error: Error #474: ; 0: no psect specified for function variable/argument allocation Have I tripped over some vagarity of C syntax here? This error doesn't reference any particular line, but if I comment out the user_main() call, it goes away. (This might be the compiler removing a redundant code branch, but the HiTech PICC32 isn't particularly smart in Lite mode, so maybe not.)

    Read the article

  • Problem with array of elements of a structure type

    - by kobac
    I'm writing an app in Visual Studio C++ and I have problem with assigning values to the elements of the array, which is array of elements of structure type. Compiler is reporting syntax error for the assigning part of the code. Is it possible in anyway to assign elements of array which are of structure type? typedef struct { CString x; double y; } Point; Point p[3]; p[0] = {"first", 10.0}; p[1] = {"second", 20.0}; p[2] = {"third", 30.0};

    Read the article

  • structures, inheritance and definition

    - by Meloun
    Hi, i need to help with structures, inheritance and definition. //define struct struct tStruct1{ int a; }; //definition tStruct1 struct1{1}; and inheritance struct tStruct2:tStruct1{ int b; }; How can I define it in declaration line? tStruct2 struct2{ ????? }; One more question, how can i use inheritance for structures defined with typedef struct?

    Read the article

  • iPhone/Objective-C struct question my own CGRectZero

    - by Mark
    I am designing a Padding struct as follows: /* Padding. */ struct CGPadding { CGFloat left; CGFloat top; CGFloat right; CGFloat bottom; }; typedef struct CGPadding CGPadding; CG_INLINE CGPadding CGPaddingMake(CGFloat left, CGFloat top, CGFloat right, CGFloat bottom) { CGPadding p; p.left = left; p.top = top; p.right = right; p.bottom = bottom; return p; } This all works perfectly well, the problem is how can I create a const CGPadding CGPaddingZero? If I do like this: const CGPadding CGPaddingZero = (CGPadding){0.0, 0.0, 0.0, 0.0}; It doesnt work. So what am I doing wrong?

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >