Hi, I have a little problem with a pointer.
In my project is included an ".h" file with this declaration:
"#define pMDMA_D0_START_ ADDR ((void * volatile *)MDMA_D0_START _ADDR)"
If I assign a value (e.g. *pMDMA_S0_START _ADDR = 0x04000;) the
compiler give me these 2 warning:
".\init.c", line 105: cc0513: {D} warning: a value of type "int" cannot
be
assigned to an entity of type "void *"
*pMDMA_S0_START _ADDR = 0x04000;
^
".\init.c", line 105: cc0152: {D} warning: conversion of nonzero
integer to
pointer
*pMDMA_S0_START _ADDR = 0x04000;
^
Why appears these warnings?
thanks, Maurizio 14 4416
mauri1106 wrote: Hi, I have a little problem with a pointer.
In my project is included an ".h" file with this declaration:
"#define pMDMA_D0_START_ ADDR ((void * volatile *)MDMA_D0_START _ADDR)"
If I assign a value (e.g. *pMDMA_S0_START _ADDR = 0x04000;) the
How is pMDMA_S0_START_ ADDR defined ?
compiler give me these 2 warning:
".\init.c", line 105: cc0513: {D} warning: a value of type "int" cannot be assigned to an entity of type "void *" *pMDMA_S0_START _ADDR = 0x04000;
^
Thats probably because your #define is pMDMA_D0_START_ ADDR
^^
and error you got points to *pMDMA_S0_START _ADDR
^^
Post the real code please !
One more suggestion is you could look at the pre-processor output
to see how your macro has expanded in the code.
- Ravi ".\init.c", line 105: cc0152: {D} warning: conversion of nonzero integer to pointer *pMDMA_S0_START _ADDR = 0x04000; ^
Why appears these warnings?
thanks, Maurizio
I'm sorry, is correct with "S0" in assegnation!
mauri1106 wrote: Hi, I have a little problem with a pointer.
In my project is included an ".h" file with this declaration:
"#define pMDMA_D0_START_ ADDR ((void * volatile *)MDMA_D0_START _ADDR)"
I assume that you also have something like the following in our header:
#define MDMA_DO_START_A DDR 0x12345678
In future, please provide a *complete* minimal example that shows the
problem (compilable, unless the problem is that it won't compiler).
If I assign a value (e.g. *pMDMA_S0_START _ADDR = 0x04000;) the compiler give me these 2 warning:
".\init.c", line 105: cc0513: {D} warning: a value of type "int" cannot be assigned to an entity of type "void *" *pMDMA_S0_START _ADDR = 0x04000;
That's simple. void* is a generic pointer type, so of course you can't
read or write through a void* pointer. You need to have a pointer to a
complete, known type, e.g. int or char.
".\init.c", line 105: cc0152: {D} warning: conversion of nonzero integer to pointer
That's simple as well. The only integer to pointer fully defined by the
C standard is that 0 converts to a null pointer. For the rest, it is
implementation defined with one possible definition being that there is
no integer type large enough to represent pointers.
*pMDMA_S0_START _ADDR = 0x04000; ^
Why appears these warnings?
Because you are writing terrible code. I'm guessing that you are trying
to access hardware directly, but depending on the OS you are using (if
you are using one) this may not be possible, but even if it is the
compiler needs to know the type of what it is trying to access.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
the correct assegantion is:
"#define pMDMA_S0_START_ ADDR ((void * volatile *)MDMA_S0_START _ADDR)"
The code is very simple and in prctice is only this declaration, the
others parts work correctly.
Thanks
mauri1106 wrote: Hi, I have a little problem with a pointer.
In my project is included an ".h" file with this declaration:
"#define pMDMA_D0_START_ ADDR ((void * volatile *)MDMA_D0_START _ADDR)"
If I assign a value (e.g. *pMDMA_S0_START _ADDR = 0x04000;) the compiler give me these 2 warning:
".\init.c", line 105: cc0513: {D} warning: a value of type "int" cannot be assigned to an entity of type "void *" *pMDMA_S0_START _ADDR = 0x04000; ^ ".\init.c", line 105: cc0152: {D} warning: conversion of nonzero integer to pointer *pMDMA_S0_START _ADDR = 0x04000; ^ Why appears these warnings?
thanks, Maurizio
Searching the archives of the group would give the complete discussion
about this section.
Here's a snippet from standard:
"An integer may be converted to any pointer type. Except as previously
specified, the result is implementation-defined, might not be correctly
aligned, might not point to an entity of the referenced type, and might
be a trap representation. "
And hence the warnings from the compiler
--
(Welcome) http://www.ungerhu.com/jxh/clc.welcome.txt
(clc FAQ) http://www.eskimo.com/~scs/C-faq/top.html
Dear anand, can you better explain your answer? I don't understand what
do you want to say.
thanks
<quote-correction>
mauri1106: Please ensure to quote the previous reply. This gives a
context to the mail. I've corrected this time.
</quote-correction> Anand Wrote:
Here's a snippet from standard: "An integer may be converted to any pointer type. Except as previously specified, the result is implementation-defined, might not be
correctly >aligned, might not point to an entity of the referenced type,
and might >be a trap representation. " mauri1106 wrote: Dear anand, can you better explain your answer? I don't understand what do you want to say. thanks
I assume you didn't search the archives of this group.
What you have is a void**ptr. So the moment you redirect it you have is
a void* (a pointer) and you are assigning an integer value to it.
And hence the warnings.
"ptr <- integer" is an implementation defined behavior and it's not
guaranteed to work.
Anyway, only valid and portable integer value that can be assigned to
any pointer is 0. (Which is NULL pointer).
If you are trying to assign any other integer to the pointer it purely
depends on your compiler and platform as to how to treat it.
The hard coded integer value you are assigning is purely dependent on
your environment in which the code is going to run.
For all you know you memory location 0x04000 could be invalid (you might
not have access to it).
Or there's no way to represent a memory location using just integers in
your system.
There are times when this may be valid (and in those cases you are very
much aware of it.) But then it's still the duty of your compiler to warn
you.
Now you decide, do you always have access to 0x4000 memory location (if
that's how you refer a location in your system) is valid and you have
full rights and doesn't cause any problem in that particular system.
--
(Welcome) http://www.ungerhu.com/jxh/clc.welcome.txt
(clc FAQ) http://www.eskimo.com/~scs/C-faq/top.html
Flash Gordon wrote: mauri1106 wrote:
[...] "#define pMDMA_D0_START_ ADDR ((void * volatile *)MDMA_D0_START _ADDR)"
[...]
".\init.c", line 105: cc0513: {D} warning: a value of type "int" cannot be assigned to an entity of type "void *" *pMDMA_S0_START _ADDR = 0x04000;
That's simple. void* is a generic pointer type, so of course you can't read or write through a void* pointer. You need to have a pointer to a complete, known type, e.g. int or char.
[...]
That's void** (or at least that's what it's type casted to). So in that
case doesn't it qualify to be a complete type? (of void*)
So for a "void *ptr" , doing "*ptr" is invalid.
But for "void **ptr", doing "*ptr" is fully valid.
Or did I miss something?
--
(Welcome) http://www.ungerhu.com/jxh/clc.welcome.txt
(clc FAQ) http://www.eskimo.com/~scs/C-faq/top.html
Anand <An***@no-replies.com> writes: mauri1106 wrote: Hi, I have a little problem with a pointer. In my project is included an ".h" file with this declaration: "#define pMDMA_D0_START_ ADDR ((void * volatile *)MDMA_D0_START _ADDR)" If I assign a value (e.g. *pMDMA_S0_START _ADDR = 0x04000;) the compiler give me these 2 warning: ".\init.c", line 105: cc0513: {D} warning: a value of type "int" cannot be assigned to an entity of type "void *" *pMDMA_S0_START _ADDR = 0x04000; ^ ".\init.c", line 105: cc0152: {D} warning: conversion of nonzero integer to pointer *pMDMA_S0_START _ADDR = 0x04000; ^ Why appears these warnings? thanks, Maurizio Searching the archives of the group would give the complete discussion about this section.
Here's a snippet from standard: "An integer may be converted to any pointer type. Except as previously specified, the result is implementation-defined, might not be correctly aligned, might not point to an entity of the referenced type, and might be a trap representation. "
And hence the warnings from the compiler
In addition, the only *implicit* integer-to-pointer conversion is for
a null pointer constant. You can convert an integer value such as
0x04000 to a pointer type, but only with an explicit cast -- and of
course the result may or may not be meaningful.
void *p0 = 0; /* ok, 0 is a null pointer constant */
void *p1 = 42; /* illegal */
void *p2 = (void*)42; /* legal but questionable */
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Carsten Spieß |
last post by:
Hello all,
i have a problem with a template constructor
I reduced my code to the following (compiled with gcc 2.7.2) to show
my problem:
// a base class
class Base{};
// two derived classes
|
by: Davy |
last post by:
Hi all,
I found
char x={"my"};
can be compiled.
But
char x;
x={"my"};
can not be compiled.
|
by: John N. |
last post by:
Hi All,
Here I have a linked list each containing a char and is double linked.
Then I have a pointer to an item in that list which is the current
insertion point.
In this funtion, the user hits the right
and left keys to move this insertion point (cursor)
Here is the problem:
|
by: Patrik Huber |
last post by:
Hello!
I got the following Code in Assembler (NASM), which prints out "5" in
realmode:
mov ax, 0xB800
mov es, ax
mov byte , '5'
I want to do the same in gcc now, but I'm stuck. GCC doesn't like the
|
by: intrepid_dw |
last post by:
Hello, all.
I've created a C# dll that contains, among other things, two functions
dealing with byte arrays. The first is a function that returns a byte
array, and the other is intended to receive a byte array as one of its
parameters. The project is marked for COM interop, and that all
proceeds normally.
When I reference the type library in the VB6 project, and write the
code to call the function that returns the byte array, it works
| |
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen. It is
almost like it is trying to implement it's own COM interfaces...
below is the header, and a link to the dll+code:
Zip file with header, example, and DLL:...
|
by: ajikoe |
last post by:
Hi,
I tried to follow the example in swig homepage.
I found error which I don't understand.
I use bcc32, I already include directory where my python.h exist in
bcc32.cfg.
/* File : example.c */
#include <time.h>
|
by: Marcelo |
last post by:
Hi everybody,
I don't understand why I am having a problem in this code.
The problem is that my pointer *phist in main method, it is declared.
Then I send the pointer to my method, and this method creates a new object (a
Matrix) for it.
I suppose that after the new operator, my pointer is pointing to an object, so
when the method has finished, the very first pointer is still poitint to the
created method; however this is not working,...
|
by: Martin Jørgensen |
last post by:
Hi,
I'm relatively new with C-programming and even though I've read about
pointers and arrays many times, it's a topic that is a little confusing
to me - at least at this moment:
----
1) What's the difference between these 3 statements:
(i) memcpy(&b, &KoefD, n); // this works somewhere in my code
|
by: iskeletor |
last post by:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define STUDENT_NUMBER 68
#define ARRAY_LENGTH 10
struct node{
char Name,Surname;
int data,no;
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |