compiler error

This is a discussion on compiler error within the C++ Programming forums, part of the General Programming Boards category; Hi, when ever I run the function below I get a compiler error saying ISO c++ forbids comparison between pointer ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    17

    compiler error

    Hi, when ever I run the function below I get a compiler error saying ISO c++ forbids comparison between pointer and integer, please help.


    Code:
    void Choice_cb(Fl_Widget*, void*v) {
    	int *g = (int*)g;
    	
    	printf("%d\n", g);
    	if (g == 1)
    		printf("C Programming\n");
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So don't compare a pointer (g) with an integer (1). Doing so is not legal. Perhaps you wish to use the integer g points to instead?

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    17
    whoops that was supposed to be int *g = (int*)v.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    g is still a pointer, though.

  5. #5
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Can we get a ruling from Overworked_PhD on that, tabstop?

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by rags_to_riches View Post
    Can we get a ruling from Overworked_PhD on that, tabstop?
    I have been very careful to avoid the word "address".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21