Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

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


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

error: conversion to non-scalar type requested


/* DDR Config3 register */

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

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);

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

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
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, 10:02 AM   #3
Senior Member
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
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.


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

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 08:01 AM
Casting to non-scalar type in C mvr853 Programming 5 06-11-2007 06:04 PM
Host found but no data record of requested type gokiwiinternet Linux - Software 3 08-29-2006 08:38 AM
server_ids2.c:367: conversion to non-scalar type requested cynthia_thomas Programming 1 02-28-2006 08:07 AM
c + type conversion dilberim82 Programming 8 03-08-2005 01:17 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:21 PM.

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