Search Results

Search found 3592 results on 144 pages for 'pointer'.

Page 30/144 | < Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >

  • Why aren't operator conversions implicitly called for templated functions? (C++)

    - by John Gordon
    I have the following code: template <class T> struct pointer { operator pointer<const T>() const; }; void f(pointer<const float>); template <typename U> void tf(pointer<const float>); void g() { pointer<float> ptr; f(ptr); tf(ptr); } When I compile the code with gcc 4.3.3 I get a message (aaa.cc:17: error: no matching function for call to ‘tf(pointer<float>&)’) indicating that the compiler called 'operator pointer<const T>' for the non-templated function f(), but didn't for the templated function tf(). Why and is there any workaround short of overloading tf() with a const and non-const version? Thanks in advance for any help.

    Read the article

  • Ubuntu 12.04.1 LTS -touch pad scroll for asus-k55v not working

    - by Aks
    have tried all the commands over terminal but still could bot fix it, for xinput i got Virtual core pointer id=2 [master pointer (3)] ? ? Virtual core XTEST pointer id=4 [slave pointer (2)] ? ? MOSART Semi. 2.4G Keyboard Mouse id=11 [slave pointer (2)] ? ? PS/2 Generic Mouse id=15 [slave pointer (2)] ? Virtual core keyboard id=3 [master keyboard (2)] ? Virtual core XTEST keyboard id=5 [slave keyboard (3)] ? Power Button id=6 [slave keyboard (3)] ? Video Bus id=7 [slave keyboard (3)] ? Video Bus id=8 [slave keyboard (3)] ? Sleep Button id=9 [slave keyboard (3)] ? MOSART Semi. 2.4G Keyboard Mouse id=10 [slave keyboard (3)] ? USB 2.0 UVC HD Webcam id=12 [slave keyboard (3)] ? Asus WMI hotkeys id=13 [slave keyboard (3)] ? AT Translated Set 2 keyboard id=14 [slave keyboard (3)] none of the post cud help to fix it :( help

    Read the article

  • Touchpad is recognized but not working on Toshiba P855-S5312 - Ubuntu 12.10

    - by user107942
    i just made a new fresh install of ubuntu 12.10, everything works nice but the touchpad istn working, it is recognized but it is not working, here a paste bin of what i get when I type "xinput list" http://paste.ubuntu.com/1357219/ b0w@b0w:~$ xinput list ? Virtual core pointer id=2 [master pointer (3)] ? ? Virtual core XTEST pointer id=4 [slave pointer (2)] ? ? Genius Optical Mouse id=9 [slave pointer (2)] ? ? SynPS/2 Synaptics TouchPad id=12 [slave pointer (2)] ? Virtual core keyboard id=3 [master keyboard (2)] ? Virtual core XTEST keyboard id=5 [slave keyboard (3)] ? Power Button id=6 [slave keyboard (3)] ? Video Bus id=7 [slave keyboard (3)] ? Power Button id=8 [slave keyboard (3)] ? TOSHIBA Web Camera - HD id=10 [slave keyboard (3)] ? AT Translated Set 2 keyboard id=11 [slave keyboard (3)] ? Toshiba input device id=13 [slave keyboard (3)] b0w@b0w:~$

    Read the article

  • Objective-C error... Cannot convert to pointer type (int)

    - by Flash84x
    I am attempting to use the TouchXML library and followed the example with the following code for (CXMLElement node in nodes) { NSMutableDictionary *item = [[NSMutableDictionary alloc] init]; int counter; for (counter = 0; counter < [node childCount]; counter++ ) { [item setObject:[[node childAtIndex:counter] stringValue] forKey:[[node childAtIndex:counter] name]]; } [rst addObject:item]; [item release]; } The compiler however is complaining about counter and throwing the following error for counter = 0 and both occurances in the setObject call. Cannot convert to pointer type Any help with my rusty C/ObjC would be appreciated

    Read the article

  • iPhone - Get a pointer to the data behind CGDataProvider?

    - by jtrim
    I'm trying to take a CGImage and copy its data into a buffer for later processing. The code below is what I have so far, but there's one thing I don't like about it - it's copying the image data twice. Once for CGDataProviderCopyData() and once for the :getBytes:length call on imgData. I haven't been able to find a way to copy the image data directly into my buffer and cut out the CGDataProviderCopyData() step, but there has to be a way...any pointers? (...pun ftw) NSData *imgData = (NSData *)(CGDataProviderCopyData(CGImageGetDataProvider(myCGImageRef))); CGImageRelease(myCGImageRef); // i've got a previously-defined pointer to an available buffer called "mybuff" [imgData getBytes:mybuff length:[imgData length]];

    Read the article

  • Strict pointer aliasing: any solution for a specific problem?

    - by doublep
    I have a problem caused by breaking strict pointer aliasing rule. I have a type T that comes from a template and some integral type Int of the same size (as with sizeof). My code essentially does the following: T x = some_other_t; if (*reinterpret_cast <Int*> (&x) == 0) ... Because T is some arbitary (other than the size restriction) type that could have a constructor, I cannot make a union of T and Int. (This is allowed only in C++0x only and isn't even supported by GCC yet). Is there any way I could rewrite the above pseudocode to preserve functionality and avoid breaking strict aliasing rule? Note that this is a template, I cannot control T or value of some_other_t; the assignment and subsequent comparison do happen inside the templated code. (For the record, the above code started breaking on GCC 4.5 if T contains any bit fields.)

    Read the article

  • How do you move the pointer up or down multiple lines with Emacs?

    - by Peter
    I can move my pointer up and down one line with my arrow key just fine in Emacs, so I'd like to redefine C-n and C-p to move up and down 5 lines at a time. I'm just beginning to learn how to use Emacs, and elisp is very alien to me. I tried using the GNU Emacs lisp reference, but I couldn't find how to bind a keystroke to multiple commands. Here's what I have so far (concentrating on the moving up definition): (global-set-key "\C-p" '(loop for i in '(1 2 3 4 5) do ('previous-line))) But, this brings up an error message when I hit C-p, "Wrong type argument." Any suggestions? Thanks!

    Read the article

  • How to attach boost::shared_ptr (or another smart pointer) to reference counter of object's parent?

    - by Checkers
    I remember encountering this concept before, but can't find it in Google now. If I have an object of type A, which directly embeds an object of type B: class A { B b; }; How can I have a smart pointer to B, e. g. boost::shared_ptr<B>, but use reference count of A? Assume an instance of A itself is heap-allocated I can safely get its shared count using, say, enable_shared_from_this.

    Read the article

  • When should an array name be treated as a pointer and when does it just represent the array itself? [duplicate]

    - by user1087373
    This question already has an answer here: When is an array name or a function name 'converted' into a pointer ? (in C) 4 answers I just made a test program after reading the book and the result turned out confusing: #include <stdio.h> int main(void) { char text[] = "hello!"; printf("sizeof(text):%d sizeof(text+2):%d sizeof(text[0]):%d \n",(int)sizeof(text), sizeof(text+2), sizeof(text[0])); printf("text:%p sizeof(text):%d &text:%p sizeof(&text):%d \n",text, sizeof(text), &text, sizeof(&text)); printf("text+1:%p &text+1:%p \n", text+1, &text+1); return 0; } The result: sizeof(text):7 sizeof(text+2):4 sizeof(text[0]):1 text:0xbfc8769d sizeof(text):7 &text:0xbfc8769d sizeof(&text):4 text+1:0xbfc8769e &text+1:0xbfc876a4 What makes me feel confused are: why the value of 'sizeof(text)' is 7 whereas 'sizeof(text+2)' is 4 what's the difference between 'text' and '&text'?

    Read the article

  • Is it possible to reinterpret pointer as dimensioned array reference?

    - by aaa
    hi. Suppose I have some pointer, which I want to reinterpret as static dimension array reference: double *p; double (&r)[4] = ?(p); // some construct? // clarify template< size_t N> void function(double (&a)[N]); ... double *p; function(p); // this will not work. // I would like to cast p as to make it appear as double[N] Is it possible to do so? how do I do it?

    Read the article

  • Returning pointer to a certain value in a macro?

    - by Andrei Ciobanu
    Is it possible to write a macro that has a type and a value as its input parameters (MACRO(type,value)), and returns a valid pointer to a location that holds the submitted value. This macro should perform like the following function, but in a more generic manner: int *val_to_ptr(int val){ int *r = NULL; r = nm_malloc(sizeof(*r)); *r = val; return r; } Where nm_malloc() is a failsafe malloc. The Macro usage should be compatible with this usage: printf("%d",*MACRO(int,5)); Is it possible to achieve that ?

    Read the article

  • Passing array to function with pointer loses array size information!

    - by Narek
    If I write int main() { int a[100] = {1,2,3,4,}; cout<<sizeof(a)/sizeof(a[0])<<endl; return 0; } I get 400! If I write void func(int *a); int main() { int a[100] = {1,2,3,4,}; func(a); return 0; } void func(int *a) { cout<<sizeof(a)/sizeof(a[0])<<endl; } Then I get 400! So why passing array to function with pointer loses array size information?

    Read the article

  • How can a FILE* (pointer to a struct) be tested (if == NULL)?

    - by m4design
    I was playing around with C, anyways I was thinking how can file pointer (which points to a struct type), be tested if NULL as for instant: FILE *cfPtr; if ( ( cfPtr = fopen( "file.dat", "w" ) ) == NULL ) I tried to do that myself, but an error occurs. struct foo{ int x; }; struct foo bar = {0}; if (bar == NULL) puts("Yay\n"); else puts("Nay"); error C2088: '==' : illegal for struct Here's the FILE deceleration in the stdio.h file: struct _iobuf { char *_ptr; int _cnt; char *_base; int _flag; int _file; int _charbuf; int _bufsiz; char *_tmpfname; }; typedef struct _iobuf FILE;

    Read the article

  • How to get function's name from function's pointer in C?

    - by Daniel Silveira
    How to get function's name from function's pointer in C? Edit: The real case is: I'm writing a linux kernel module and I'm calling kernel functions. Some of these functions are pointers and I want to inspect the code of that function in the kernel source. But I don't know which function it is pointing to. I thought it could be done because, when the system fails (kernel panic) it prints out in the screen the current callstack with function's names. But, I guess I was wrong... am I?

    Read the article

  • How can I assign pointer member with long string?

    - by Nano HE
    Hi, When I did the practice below to erase my pointer member and assign new value to it. (*pMyPointer).member.erase(); (*pMyPointer).member.assign("Hello"); // Successfully Than I tried more... (*pMyPointer).member.erase(); (*pMyPointer).member.assign("Long Multi Lines Format String"); // How to? If the long multi lines string can't quote by double quoter, how to handle it. Thank you.

    Read the article

  • Why doesn't C++ allow you to request a pointer to the most derived class?

    - by Matthew Lowe
    (This question should probably be answered with a reference to Stroustrup.) It seems extremely useful to be able to request a pointer to the most derived class, as in the following: class Base { ... }; class DerivedA { ... }; class DerivedB { ... }; class Processor { public: void Do(Base* b) {...} void Do(DerivedA* d) {...} void Do(DerivedB* d) {...} }; list<Base*> things; Processor p; for(list<Base*>::iterator i=things.begin(), e=things.end(); i!=e; ++i) { p.Do(CAST_TO_MOST_DERIVED_CLASS(*i)); } But this mechanism isn't provided in c++. Why?

    Read the article

  • How to move file pointer to a particular location using fseek()?

    - by Noge
    My intention is to read every elements in the 2nd column into a buffer[] from the following .txt file: 9992891234 09.920 15.771 11.909 9992345971 07.892 12.234 09.234 9992348971 64.567 70.456 50.987 9992348231 89.234 85.890 58.982 I have know of a way to do it by using fscanf(): for (int i=0;i<4;i++) { fscanf(pFile, "%lld", &junk); fscanf(pFile, "%f", &buffer[i]); fscanf(pFile, "%f", &junk); fscanf(pFile, "%f", &junk); } However, since I'm doing parallel programing which requires me to use different Windows Threads to read different columns, so I'll need to read the elements in the 2nd column directly using fseek(). The question here is, what should I put in the 2nd argument in fseek() in the code below to move my file pointer to read the 2nd element of the 2nd line? fscanf(pFile, "%llf", &junk);//<------this is used to skip the 1st data for (int i=0;i<4;i++) { fscanf(pFile, "%f", &buffer[i]); fseek ( pFile , ??, SEEK_CUR );//<----how do I calculate this offset? }

    Read the article

  • How do I read UTF-8 characters via a pointer?

    - by Jen
    Suppose I have UTF-8 content stored in memory, how do I read the characters using a pointer? I presume I need to watch for the 8th bit indicating a multi-byte character, but how exactly do I turn the sequence into a valid Unicode character? Also, is wchar_t the proper type to store a single Unicode character? This is what I have in mind: wchar_t readNextChar (char** p) { char ch = *p++; if (ch & 128) { // This is a multi-byte character, what do I do now? // char chNext = *p++; // ... but how do I assemble the Unicode character? ... } ... }

    Read the article

  • How to declare a pointer to a variable as a parameter of a function in C++?

    - by Keand64
    I have a function that takes a pointer to a D3DXVECTOR3, but I have no reason to declare this beforehand. The most logical solution to me was using new: Function( //other parameters, new D3DXVECTOR3(x, y, 0)); but I don't know how I would go about deleting it, beign intitialized in a function. My next thought was to use the & operator, like so: Function( //other parameters, &D3DVECTOR3(x, y, 0)); but I don't know if this is a valid way to go about doing this. (It doesn't get an error, but neither does int *x; x = 50;). So should I use new, &, or some other technique I'm overlooking?

    Read the article

< Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >