473,480 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

compile error in demo program

I get a compile error at line 285 of this demo
error converting from void* to pollfd*
Do I need to set some compiler flag ?
I did not write this so I'm reluctant to change anything.
251
252 /*
253 * Transfer method - write and wait for room in buffer using
poll
254 */
255
256 static int wait_for_poll(snd_pcm_t *handle, struct pollfd *ufds,
unsigned int count)
257 {
258 unsigned short revents;
259
260 while (1) {
261 poll(ufds, count, -1);
262 snd_pcm_poll_descriptors_revents(handle, ufds,
count, &revents);
263 if (revents & POLLERR)
264 return -EIO;
265 if (revents & POLLOUT)
266 return 0;
267 }
268 }
269
270 static int write_and_poll_loop(snd_pcm_t *handle,
271 signed short *samples,
272 snd_pcm_channel_area_t *areas)
273 {
274 struct pollfd *ufds;
275 double phase = 0;
276 signed short *ptr;
277 int err, count, cptr, init;
278
279 count = snd_pcm_poll_descriptors_count (handle);
280 if (count <= 0) {
281 printf("Invalid poll descriptors count\n");
282 return count;
283 }
284
285 ufds = malloc(sizeof(struct pollfd) * count);

Jun 1 '06 #1
2 2261
vf***@talktalk.net escribió:
I get a compile error at line 285 of this demo
error converting from void* to pollfd*
Do I need to set some compiler flag ?
I did not write this so I'm reluctant to change anything.
251
252 /*
253 * Transfer method - write and wait for room in buffer using
poll
254 */
255
256 static int wait_for_poll(snd_pcm_t *handle, struct pollfd *ufds,
unsigned int count)
257 {
258 unsigned short revents;
259
260 while (1) {
261 poll(ufds, count, -1);
262 snd_pcm_poll_descriptors_revents(handle, ufds,
count, &revents);
263 if (revents & POLLERR)
264 return -EIO;
265 if (revents & POLLOUT)
266 return 0;
267 }
268 }
269
270 static int write_and_poll_loop(snd_pcm_t *handle,
271 signed short *samples,
272 snd_pcm_channel_area_t *areas)
273 {
274 struct pollfd *ufds;
275 double phase = 0;
276 signed short *ptr;
277 int err, count, cptr, init;
278
279 count = snd_pcm_poll_descriptors_count (handle);
280 if (count <= 0) {
281 printf("Invalid poll descriptors count\n");
282 return count;
283 }
284
285 ufds = malloc(sizeof(struct pollfd) * count);


It should be:

ufds = (struct pollfd*)malloc(sizeof(struct pollfd) * count);

This code looks like C though, if you happen to need more help you might
wanna try on comp.lang.c instead.

- Eduardo Grajeda -
Jun 1 '06 #2
vf***@talktalk.net <vf***@talktalk.net> wrote:
I get a compile error at line 285 of this demo
error converting from void* to pollfd*
Do I need to set some compiler flag ?
I did not write this so I'm reluctant to change anything.

285 ufds = malloc(sizeof(struct pollfd) * count);


This looks like C, not C++. In C, it is better not to cast the result
of malloc() because this can hide the fact that you forgot to #include
<stdlib.h>. However, in C++, you need to cast the result of malloc()
since C++ doesn't allow the implicit conversion from void* to another
pointer type. In C++, "new" is usually used instead of malloc() since
new is type-safe whereas malloc() is not, and "new" will construct
objects whereas malloc() basically only reserves memory.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jun 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2092
by: John Kinson | last post by:
Hi, I'm trying to get the wxPython demo to run on a Debian sarge testing installation, but encounter the following error when I run the demo script: # ./demo.py Traceback (most recent call...
9
6742
by: Brian | last post by:
Greetings: I am trying to compile the following code via command line. It compiles just fine in visual studio 2002 v7 so i took looked at the properties and i got the following command line...
3
1167
by: David | last post by:
Hi, why I have compile error as follows? r.cpp: In function `int main ()': r.cpp:40: call of overloaded `change(Demo &)' is ambiguous r.cpp:11: candidates are: void Demo::change (Demo)...
3
4560
by: Andrew Luke | last post by:
Hi all you C++ guru's! I'm 'very, very' new to C++ and I'm having a little trouble configuring my VS environment I think - when I try and compile some sample code I'm getting the following...
5
3784
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace )...
2
1150
by: Nak | last post by:
Hi there, I have implemented pre-compile variable evaluation in my application to create a "Demo" version of my application with limited functionality. I would like to use this easy method...
2
4113
by: BruceWho | last post by:
I downloaded boost1.35.0 and built it with following command: bjam --toolset=msvc-7.1 --variant=release --threading=multi -- link=shared --with-system stage and it failed to compile, error...
2
6631
myusernotyours
by: myusernotyours | last post by:
Hi All, Am working on a Java application in which I have to use the JNI to Interface with some native code for both windows and unix. Am using netbeans IDE with the C/C++ pack installed. Am also...
0
7046
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7048
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6741
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...
0
6956
tracyyun
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...
1
4783
isladogs
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...
0
4485
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...
0
2997
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...
0
1300
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.