LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-01-2010, 10:40 PM   #1
Kenny_Strawn
Senior Member
 
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Blog Entries: 62

Rep: Reputation: 54
GCC compilation error


This is the error that I now suddenly get in this line to a class of mine (and it's the ONLY error):

Code:
librgbamap.c:11: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
First of all what does this error mean? Secondly, this is the line that triggered it (and didn't before):

Code:
unsigned long rgbCube = Red * Green * Blue;
There should be nothing wrong with this line. I in fact had no errors in other similar lines.

Edit: Fixed by making the class a function and changing other errors within my code as an update to my customizable GTK RGBA module. Here is the full code:

Code:
#include <glib.h>
#include <glib/gtypes.h>
#include <gtk/gtk.h>

void rgbamap(unsigned long Red, unsigned long Green, unsigned long Blue, float Alpha) {

	unsigned long rgbCube = Red * Green * Blue;
	
	double aRed = Alpha*(Red);
	double aGreen = Alpha*(Green);
	double aBlue = Alpha*(Blue);
	
	double rBlend = (1 - Alpha)*Red + Alpha*(aRed);
	double gBlend = (1 - Alpha)*Green + Alpha*(aGreen);
	double bBlend = (1 - Alpha)*Blue + Alpha*(aBlue);
        return;
};

Last edited by Kenny_Strawn; 07-01-2010 at 11:15 PM. Reason: Added return statement to function
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 07-01-2010, 10:47 PM   #2
MrCode
Member
 
Registered: Aug 2009
Location: Oregon, USA
Distribution: Arch
Posts: 859
Blog Entries: 31

Rep: Reputation: 144Reputation: 144
I assume you're talking about the code you posted in this thread? It would be better if you posted it here, so that other members won't have to keep referring to that thread to see your code...

Are you still using those nonsensical "<=" variable assignments? I really don't see the logic in that...why are you trying to compare something before it even has a value assigned to it? I would tend to guess that's the cause of your problem.

EDIT: Thanks for posting your code.

Quote:
Reason: Fixed the error
So, GCC isn't complaining anymore? Problem solved?

Last edited by MrCode; 07-01-2010 at 10:52 PM.
 
Old 07-01-2010, 10:50 PM   #3
Kenny_Strawn
Senior Member
 
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Blog Entries: 62

Original Poster
Rep: Reputation: 54
Original post modified.
 
Old 07-01-2010, 11:13 PM   #4
Kenny_Strawn
Senior Member
 
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Blog Entries: 62

Original Poster
Rep: Reputation: 54
Quote:
Originally Posted by MrCode View Post
So, GCC isn't complaining anymore? Problem solved?
After changing the class to a function, yes.
 
Old 07-01-2010, 11:32 PM   #5
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora, Arch
Posts: 488

Rep: Reputation: 58
When the compiler tells me it expected a ';' on line 11, it usually means I forgot to put ';' at the end of line 10.
 
Old 07-01-2010, 11:35 PM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,123

Rep: Reputation: 407Reputation: 407Reputation: 407Reputation: 407Reputation: 407
Quote:
Originally Posted by Kenny_Strawn View Post
...
Here is the full code:

Code:
#include <glib.h>
#include <glib/gtypes.h>
#include <gtk/gtk.h>

void rgbamap(unsigned long Red, unsigned long Green, unsigned long Blue, float Alpha) {

	unsigned long rgbCube = Red * Green * Blue;
	
	double aRed = Alpha*(Red);
	double aGreen = Alpha*(Green);
	double aBlue = Alpha*(Blue);
	
	double rBlend = (1 - Alpha)*Red + Alpha*(aRed);
	double gBlend = (1 - Alpha)*Green + Alpha*(aGreen);
	double bBlend = (1 - Alpha)*Blue + Alpha*(aBlue);
        return;
};
Still senseless code. Still senselessly includes gtk+ related files and still senselessly burns CPU cycles not changing anything in the calling scope.
 
Old 07-01-2010, 11:50 PM   #7
easuter
Member
 
Registered: Dec 2005
Location: Portugal
Distribution: Slackware64 13.0, Slackware64 13.1
Posts: 534

Rep: Reputation: 62
Quote:
Originally Posted by Sergei Steshenko View Post
Still senseless code. Still senselessly includes gtk+ related files and still senselessly burns CPU cycles not changing anything in the calling scope.
There really is no point arguing with Mr. Strawn (eg: http://www.linuxquestions.org/questi...ml#post4021086).

Until he decides to write some scaffolding to test his code like any sane programmer does, I suspect we're going to continue to see a torrent of stupid and pointless posts flooding this sub-forum.
 
Old 07-02-2010, 12:07 AM   #8
Kenny_Strawn
Senior Member
 
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Blog Entries: 62

Original Poster
Rep: Reputation: 54
Quote:
Originally Posted by easuter View Post
There really is no point arguing with Mr. Strawn (eg: http://www.linuxquestions.org/questi...ml#post4021086).

Until he decides to write some scaffolding to test his code like any sane programmer does, I suspect we're going to continue to see a torrent of stupid and pointless posts flooding this sub-forum.
I tried testing the function in the Linux Mint default gtkrc, and for some reason it didn't work (looked like a classic theme).

I am going to have to rewrite it or something.
 
Old 07-02-2010, 12:11 AM   #9
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,123

Rep: Reputation: 407Reputation: 407Reputation: 407Reputation: 407Reputation: 407
Quote:
Originally Posted by Kenny_Strawn View Post
...for some reason it didn't work ...
It didn't work because you completely miss fundamental concepts of programming. As a result you are writing senseless code with which you spam this forum.
 
Old 07-02-2010, 12:35 AM   #10
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
Quote:
Originally Posted by Kenny_Strawn View Post
for some reason it didn't work (looked like a classic theme).
Uhm -- lol. "Some reason" could be that your code does a handful of computations, only to throw the results completely away. Really, learn some structured/imperative programming first, start with "hello world¨...
 
Old 07-02-2010, 05:16 PM   #11
Kenny_Strawn
Senior Member
 
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Blog Entries: 62

Original Poster
Rep: Reputation: 54
Code modified so that the inclusion of GTK-related files isn't senseless:

Code:
#include <glib.h>
#include <glib/gtypes.h>
#include <gtk/gtk.h>

void rgba(guint16 Red, guint16 Green, guint16 Blue, float Alpha) {
    guint32 pixel;

    double aRed = Alpha*(Red);
    double aGreen = Alpha*(Green);
    double aBlue = Alpha*(Blue);
	
    double rBlend = (1 - Alpha)*Red + Alpha*(aRed);
    double gBlend = (1 - Alpha)*Green + Alpha*(aGreen);
    double bBlend = (1 - Alpha)*Blue + Alpha*(aBlue);
    return;
}
Note the GTK-specific guint16 and guint32 declarations and the use of the 'pixel' declaration. Now GTK-related files are included for a purpose. And the computations are formulas taken from Wikipedia for alpha blending.
 
Old 07-02-2010, 05:23 PM   #12
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
ROFL
 
0 members found this post helpful.
Old 07-02-2010, 05:37 PM   #13
Kenny_Strawn
Senior Member
 
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Blog Entries: 62

Original Poster
Rep: Reputation: 54
Quote:
Originally Posted by zirias View Post
ROFL
Reported. This is rude and an ad hominem attack. I've had enough ridicule.
 
1 members found this post helpful.
Old 07-03-2010, 12:45 AM   #14
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
Don't want to be laughed at? Don't be the clown. You had more than enough hints!
 
1 members found this post helpful.
Old 07-03-2010, 01:32 AM   #15
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Quote:
Originally Posted by zirias View Post
Don't want to be laughed at? Don't be the clown. You had more than enough hints!
Right, hints are good and were totally appropriate in this post, because the OP seems to be missing some fundamental programming concepts.

@Kenny_Strawn: you should generally not be offended if someone tells you that you need a bit better understanding of some fundamentals. That should just help you to avoid such errors in the future.

BUT, I totally agree with Kenny_Strawn, that there are different ways to tell someone to dig further into the details. And just laughing at someone is definitely NOT the correct way. I think MOST of us were beginners at some time ;-)
 
2 members found this post helpful.
  


Reply

Tags
interesting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc 4.4.3 compilation error pankajd Linux - Software 1 04-03-2010 09:50 AM
gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7) compilation error adhesh_19 Red Hat 0 01-05-2010 05:34 AM
5.4. GCC-4.0.3 - Pass 1 compilation error :( gothicbob Linux From Scratch 1 08-06-2007 05:21 PM
have gcc compilation error during gcc installtion in linuxfromscratch vbshanmugaprakash Linux - General 3 12-13-2006 05:52 AM
gcc compilation error Proger Programming 1 03-22-2003 12:32 PM


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

Main Menu
 
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
Open Source Consulting | Domain Registration