LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-22-2008, 08:28 AM   #1
TEL12345
LQ Newbie
 
Registered: Aug 2008
Posts: 1

Rep: Reputation: 0
conversion to non-scalar type requested


Hi,

When i compile a code snippet , i receive one error...

error: conversion to non-scalar type requested


Code:


/* DDR Config3 register */

typedef struct config3 {
uint32 cfg_startup_delay:17;
uint32 reserved:15;
}ddr_config3;


void main()
{
ddr_config3 ddrconfig3;
ddrconfig3 = (ddr_config3 )ddr2_reg_read ((uint32)DDR_CONFIG3);

.....
.....
.....


}
static inline uint32 ddr2_reg_read (uint32 reg)
{
volatile uint32 *reg_addr = (uint32 *) (DDR2_BASE + reg);
return *reg_addr;
}

the error was in
ddrconfig3 = (ddr_config3 )ddr2_reg_read ((uint32)DDR_CONFIG3);

Thanks
 
Old 08-22-2008, 09:01 AM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
You're trying to convert the (scalar) value returned by ddr2_reg_read to a struct, and the compiler is telling you that it doesn't "know' how to do that.

I suspect that your intention was either to set one component or the structure to the value returned, or to have the function return a structure. (In the later case, you would not need the cast.)
 
Old 08-22-2008, 09:02 AM   #3
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
You are trying to convert an uint32 (an integer that's 32 bit in length, I suppose) to a structure containing two uint32.
What do you expect the compiler to do with that? I would do exactly like him: complain that it can't.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix: Host found but no data record of requested type alex r Linux - Networking 4 06-26-2014 07:01 AM
Casting to non-scalar type in C mvr853 Programming 5 06-11-2007 05:04 PM
Host found but no data record of requested type gokiwiinternet Linux - Software 3 08-29-2006 07:38 AM
server_ids2.c:367: conversion to non-scalar type requested cynthia_thomas Programming 1 02-28-2006 07:07 AM
c + type conversion dilberim82 Programming 8 03-08-2005 12:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:33 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
Open Source Consulting | Domain Registration