LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Blogs > Kenny the one-teen comittee to stamp out Proprietary $uckware
User Name
Password

Notices

I decided to post a little introduction to myself here: Ask me who I was last March, and I would have had WinBloze 7 Beta on my main computer and would have been part of Micro$uck's test project for WinBloze 7 and would have been excited about it. However, that changed as soon as my network adapter changed and the new one worked with Linux. As soon as I tested the new adapter with Mint (I'd say about a year ago, in July 2009) I began to really value Linux for what it is.

However, I knew about Linux long before that. I started with gOS 2, which was my first distro. I had tried it back in about February 2008. I first learned about Linux back in mid-2007, from an article in PCMag that spanned several pages. I had quite a hard time back then, and Ubuntu Hardy was no different than gOS.

So then what took me so long from knowing about Linux to finally becoming an active user? My house was nothing but Wi-Fi. My mother set a secure wireless network up back then, and I couldn't connect to it because my adapter (Linksys WUSB54GSC) wasn't recognized by Linux. I had the patience to continue.

Then, in June 2008, my family got hit by the economic collapse here in the USA: The mortgage on my old house doubled and my family had to leave because of the rate increase. So, we were stuck in a hotel room until my family and I could end up in a new house. That Christmas, I wanted a netbook, and got my wish (the one I'm typing on, an Acer Aspire One AOA110-1545). It came with Linux preinstalled, and I liked it all around.

From then to June 2009, I still had WinBloze on my desktop, as Linux still didn't work with my wireless network adapter. Then, in June 2009 as I said, I got a new wireless network adapter, and in July decided to test it with Linux Mint 7. It worked, even from the Live CD! Now,

Rating: 2 votes, 1.00 average.

GCC: error: incompatible types when returning type ‘double (*)()’ but ‘double’ was expected

Posted 08-01-2010 at 05:06 PM by Kenny_Strawn

Can anyone please tell me what this error means and why I got it while trying to return the outputs of functions?

I decided to post this question in my blog instead of the programming forum, because another member in that forum always responds to posts about compilation errors with vague, 'RTFM'-like responses. Thankfully, I can use my ignore list to ban Stashenko from this blog. Not so much for the programming forum.
Posted in Uncategorized
Views 4975 Comments 24
« Prev     Main     Next »
Total Comments 24

Comments

  1. Old Comment
    Again: I want to know if anyone will help me on this error.
    Posted 08-01-2010 at 06:00 PM by Kenny_Strawn Kenny_Strawn is offline
  2. Old Comment
    So, where is the full source code ?
    Posted 08-02-2010 at 12:11 AM by Sergei Steshenko Sergei Steshenko is offline
  3. Old Comment
    Doesn't look like your ignore list worked.
    Posted 08-02-2010 at 07:04 AM by brianL brianL is offline
  4. Old Comment
    Quote:
    Originally Posted by brianL View Comment
    Doesn't look like your ignore list worked.
    No, but that's because he's not on it yet. He will be as soon as he posts vague or aggressive responses to my question.
    Posted 08-02-2010 at 10:44 AM by Kenny_Strawn Kenny_Strawn is offline
  5. Old Comment
    And here's the full source (It is supposed to be a huge improvement to some code I had before in another thread):

    Code:
    #include <glib.h>
    #include <glib/gtypes.h>
    #include <gtk/gtk.h>
    #include <gdk/gdk.h>
    #include <gdk/gdktypes.h>
    
    double rgba(guint16 Red, guint16 Green, guint16 Blue, double Alpha)
    {	
        guint32 get_pixel(guint32 x, guint32 y) {
            return x, y;
        }
    	
        struct bg_color {
    	
    	guint16 *Red;
    	for(Red >= 0; Red <= 255; Red++) {
    	    get_pixel();
    	    return Red;
    	}
    	
    	guint16 *Green;
    	for(Green >= 0; Green <= 255; Green++) {
    	    get_pixel();
                return Green;
    	}
    	
    	guint16 *Blue;
    	for(Blue >= 0; Blue <= 255; Blue++) {
    		get_pixel();
    		return Blue;
    	    }
    	}
    	
        struct fg_color {
    		
    	guint16 *Red;
    	for(Red >= 0; Red <= 255; Red++) {
    	    get_pixel();
    	    return Red;
    	}
    		
    	guint16 *Green;
    	for(Green >= 0; Green <= 255; Green++) {
    	    get_pixel();
    	    return Green;
    	}
    		
    	guint16 *Blue;
    	for(Blue >= 0; Blue <= 255; Blue++) {
    	    get_pixel();
                return Blue;
            }
        }
    	
        double *Alpha;
        for(Alpha >= 0; Alpha <= 1; Alpha++) {
    	get_pixel();
    	return Alpha;
        }
    	
        double rBlend(bg_color, fg_color) {
    	return (1-Alpha)*bg_color.Red + Alpha*(fg_color.Red);
        }
    	
        double gBlend(bg_color, fg_color) {
            return (1-Alpha)*bg_color.Green + Alpha*(fg_color.Green);
        }
    	
        double bBlend(bg_color, fg_color) {
            return (1-Alpha)*bg_color.Blue + Alpha*(fg_color.Blue);
        }
    	
        return rBlend, gBlend, bBlend;
    }
    Try to tell me a list of what's wrong with it, but not just bash it, lest I edit your comments or use the ignore list. Please read my Code of Conduct to see the full list of rules. If I can abide by them, so can you.
    Posted 08-02-2010 at 10:57 AM by Kenny_Strawn Kenny_Strawn is offline
  6. Old Comment
    Quote:
    Originally Posted by Kenny_Strawn View Comment
    And here's the full source (It is supposed to be a huge improvement to some code I had before in another thread):

    Code:
    ...
        return rBlend, gBlend, bBlend;
    ...
    Try to tell me a list of what's wrong with it, but not just bash it, lest I edit your comments or use the ignore list. Please read my Code of Conduct to see the full list of rules. If I can abide by them, so can you.
    So, based on which part of C or C++ standard did you write the only one statement in the code I left present ?
    Posted 08-02-2010 at 12:26 PM by Sergei Steshenko Sergei Steshenko is offline
  7. Old Comment
    And based on which part of C or C++ standard did you write pieces like this one:

    Code:
        struct bg_color {
    	
    	guint16 *Red;
    	for(Red >= 0; Red <= 255; Red++) {
    	    get_pixel();
    	    return Red;
    	}
    	
    	guint16 *Green;
    	for(Green >= 0; Green <= 255; Green++) {
    	    get_pixel();
                return Green;
    	}
    	
    	guint16 *Blue;
    	for(Blue >= 0; Blue <= 255; Blue++) {
    		get_pixel();
    		return Blue;
    	    }
    	}
    ?

    Specifically, what made you think you can use "return" inside a struct ?

    And what made you think you can write a loop inside a struct ?

    And what makes you think that code after first "return" is executed in the first place ?
    Posted 08-02-2010 at 12:30 PM by Sergei Steshenko Sergei Steshenko is offline
  8. Old Comment
    And what made you think you can write

    Code:
            return x, y;
    in

    Code:
        guint32 get_pixel(guint32 x, guint32 y) {
            return x, y;
        }
    ?
    Posted 08-02-2010 at 12:52 PM by Sergei Steshenko Sergei Steshenko is offline
  9. Old Comment
    And what made you think

    Code:
    	    get_pixel();
    is a right way to call 'get_pixel' function ?
    Posted 08-02-2010 at 12:53 PM by Sergei Steshenko Sergei Steshenko is offline
  10. Old Comment
    Posted 08-02-2010 at 01:11 PM by Sergei Steshenko Sergei Steshenko is offline
  11. Old Comment
    So, to summarize.

    From the point of view of C99 compliance only these pieces of your code:

    Code:
    #include <glib.h>
    #include <glib/gtypes.h>
    #include <gtk/gtk.h>
    #include <gdk/gdk.h>
    #include <gdk/gdktypes.h>
    
    double rgba(guint16 Red, guint16 Green, guint16 Blue, double Alpha)
    {	
    
    }
    make sense. And as such the code as a whole doesn't make sense - because in the code executable part there is no line which makes sense.

    But the trouble is deeper, I think. This is because in the end the code should be called from somewhere inside gtk+-based desktop. I haven't yet seen any indication that the 'rgba' function can be called from a gtk+-based desktop, i.e. I yet have to see a document proving that the 'rgba' function should have the interface you've chosen.
    Posted 08-02-2010 at 01:52 PM by Sergei Steshenko Sergei Steshenko is offline
  12. Old Comment
    The error means that you are trying to return a function-returning-double instead of a double.

    The code itself makes no sense, can you explain what you are trying to accomplish with it?
    Posted 08-02-2010 at 05:19 PM by ntubski ntubski is offline
  13. Old Comment
    Okay, now that we've got those problems cleared up I am trying to propose a total overhaul of the function (i.e. moving subfunctions out and structs out as functions). I now want to know if there's any way to printf an integer (and if not, if there's any function that can be able to output a numerical variable without using return).
    Posted 08-02-2010 at 06:47 PM by Kenny_Strawn Kenny_Strawn is offline
  14. Old Comment
    Quote:
    Originally Posted by Kenny_Strawn View Comment
    ... I now want to know if there's any way to printf an integer ...
    How interesting. Has the thought to read

    man 3 printf

    ever crossed your mind ?
    Posted 08-02-2010 at 08:47 PM by Sergei Steshenko Sergei Steshenko is offline
  15. Old Comment
    Quote:
    Originally Posted by Kenny_Strawn View Comment
    ... It is supposed to be a huge improvement to some code I had before in another thread ...
    Now that you've decided on "total overhaul of the function"

    (
    http://www.linuxquestions.org/questi...omment&bt=4338
    )

    one can see there was no improvement at all. In fact, there was just an increase in the number of senseless lines.

    If you want to write code which makes sense, as a rule (at least, in the beginning) accompany each construct of your code with a reference (chapter name, paragraph number, page number) of C99 standard: http://www.ishiboo.com/~danny/c++/C_...C9899-1999.pdf .

    If you can't justify the construct, just don't write it.
    Posted 08-02-2010 at 09:15 PM by Sergei Steshenko Sergei Steshenko is offline
  16. Old Comment
    Quote:
    Originally Posted by Sergei Steshenko View Comment
    How interesting. Has the thought to read

    man 3 printf

    ever crossed your mind ?
    Also, 'printf' appears many times in the already mentioned http://www.ishiboo.com/~danny/c++/C_...C9899-1999.pdf standard as part of standard "C" library. There are examples too.
    Posted 08-02-2010 at 11:23 PM by Sergei Steshenko Sergei Steshenko is offline
  17. Old Comment
    1. Why is there a function nested in a function?
    2. You can't return a list of values.
    3. You cannot put code in a struct. It's a data type that consists of other data types, *not* a function!
    4. What makes you think you can return from a struct? Again, a struct is *****not***** a function!
    Posted 08-03-2010 at 02:04 PM by MTK358 MTK358 is offline
  18. Old Comment
    Hi Kenny,

    I have a question:

    How old are you?

    This was the first question that came into my mind when I first saw your 'naive' attempt to write this function. So please answer this question first so that we can take your age into consideration before giving you a "RTFM" like answer.
    Posted 08-06-2010 at 10:54 PM by crts crts is offline
  19. Old Comment
    Yeah, I know that a struct is nothing more than a data type definition, after looking in my book on C++. But I also know that, while structs cannot accept sub-functions, classes can, and I also know that classes can also accept many other things, such as conditions/loops, in the confines of those functions. So, apparently I'm better off using C++ instead of C.
    Posted 08-13-2010 at 11:02 PM by Kenny_Strawn Kenny_Strawn is offline
    Updated 08-13-2010 at 11:18 PM by Kenny_Strawn
  20. Old Comment
    Quote:
    Originally Posted by Kenny_Strawn View Comment
    I'm better off using C++ instead of C.
    Your C++ code you've published here does not confirm this statement.
    Posted 08-14-2010 at 05:28 AM by Sergei Steshenko Sergei Steshenko is offline
 

  



All times are GMT -5. The time now is 03:35 AM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration