LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 04-25-2013, 04:55 AM   #1
arungpillai09054
LQ Newbie
 
Registered: Nov 2012
Posts: 7

Rep: Reputation: Disabled
how to assign a “const void*” to a “const uint64_t*” in cuda c?


I want to assign "const void*" to a "const uint64_t*" in cuda c.

I have done like this,

Code:
void func(const void *buffer)
    {
      const uint64_t *words = buffer;
    }
but i'm getting an error like this,

Quote:
error: a value of type "const void *" cannot be used to initialize an entity of type "const uint64_t*"
can anyone help me in solving this problem?
 
Old 04-25-2013, 05:40 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,864
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
typecast is the name of the magic:

Code:
const uint64_t *words = (uint64_t *)buffer;
 
Old 04-25-2013, 06:14 AM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by NevemTeve View Post
typecast is the name of the magic:

Code:
const uint64_t *words = (uint64_t *)buffer;
I think you need the const in the cast as well:

Code:
const uint64_t *words = (const uint64_t *)buffer;
 
  


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
const void* question dayalan_cse Programming 27 04-12-2013 03:54 AM
Convert const wchar_t* to const char* to use in fprintf() coders123 Programming 1 01-17-2011 03:47 PM
const? kalleanka Programming 9 08-22-2006 11:10 AM
Non-Const reference? ChemicalBurn Programming 4 04-05-2005 08:32 AM
const in C++ lazyboy0001 Programming 5 04-08-2004 04:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:09 PM.

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