Click here to Skip to main content
15,941,690 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Can Bullet numbering in Pin
Richard MacCutchan9-Dec-19 3:37
mveRichard MacCutchan9-Dec-19 3:37 
AnswerRe: Can Bullet numbering in Pin
ForNow9-Dec-19 3:55
ForNow9-Dec-19 3:55 
QuestionV2008: All my breakpoints disable. Mouseover shows "The breakpoint will not currently be hit. No executable code is associated with this line." Pin
charlieg8-Dec-19 9:42
charlieg8-Dec-19 9:42 
AnswerRe: V2008: All my breakpoints disable. Mouseover shows "The breakpoint will not currently be hit. No executable code is associated with this line." Pin
charlieg8-Dec-19 9:48
charlieg8-Dec-19 9:48 
GeneralRe: V2008: All my breakpoints disable. Mouseover shows "The breakpoint will not currently be hit. No executable code is associated with this line." Pin
leon de boer8-Dec-19 13:10
leon de boer8-Dec-19 13:10 
GeneralRe: V2008: All my breakpoints disable. Mouseover shows "The breakpoint will not currently be hit. No executable code is associated with this line." Pin
Stefan_Lang8-Dec-19 23:20
Stefan_Lang8-Dec-19 23:20 
GeneralRe: V2008: All my breakpoints disable. Mouseover shows "The breakpoint will not currently be hit. No executable code is associated with this line." Pin
leon de boer9-Dec-19 0:52
leon de boer9-Dec-19 0:52 
GeneralRe: V2008: All my breakpoints disable. Mouseover shows "The breakpoint will not currently be hit. No executable code is associated with this line." Pin
Stefan_Lang9-Dec-19 1:59
Stefan_Lang9-Dec-19 1:59 
GeneralRe: V2008: All my breakpoints disable. Mouseover shows "The breakpoint will not currently be hit. No executable code is associated with this line." Pin
charlieg9-Dec-19 2:05
charlieg9-Dec-19 2:05 
AnswerRe: V2008: All my breakpoints disable. Mouseover shows "The breakpoint will not currently be hit. No executable code is associated with this line." Pin
charlieg9-Dec-19 2:09
charlieg9-Dec-19 2:09 
AnswerRe: V2008: All my breakpoints disable. Mouseover shows "The breakpoint will not currently be hit. No executable code is associated with this line." Pin
charlieg8-Jan-20 11:37
charlieg8-Jan-20 11:37 
QuestionAllocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Vaclav_6-Dec-19 5:56
Vaclav_6-Dec-19 5:56 
AnswerRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Richard MacCutchan6-Dec-19 6:12
mveRichard MacCutchan6-Dec-19 6:12 
GeneralRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Vaclav_6-Dec-19 8:17
Vaclav_6-Dec-19 8:17 
GeneralRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Victor Nijegorodov6-Dec-19 21:39
Victor Nijegorodov6-Dec-19 21:39 
GeneralRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Richard MacCutchan6-Dec-19 22:02
mveRichard MacCutchan6-Dec-19 22:02 
GeneralRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Stefan_Lang8-Dec-19 22:13
Stefan_Lang8-Dec-19 22:13 
GeneralRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Richard MacCutchan8-Dec-19 22:21
mveRichard MacCutchan8-Dec-19 22:21 
GeneralRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Richard MacCutchan6-Dec-19 22:01
mveRichard MacCutchan6-Dec-19 22:01 
AnswerRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
CPallini8-Dec-19 22:09
mveCPallini8-Dec-19 22:09 
GeneralRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Stefan_Lang8-Dec-19 23:01
Stefan_Lang8-Dec-19 23:01 
GeneralRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
CPallini8-Dec-19 23:35
mveCPallini8-Dec-19 23:35 
AnswerRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Stefan_Lang8-Dec-19 22:47
Stefan_Lang8-Dec-19 22:47 
GeneralRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Vaclav_9-Dec-19 3:33
Vaclav_9-Dec-19 3:33 
GeneralRe: Allocating memory for struct pointer - error: invalid conversion from ‘void*’ Pin
Stefan_Lang9-Dec-19 4:11
Stefan_Lang9-Dec-19 4:11 
Thanks for responding. It's good to know a little more context.

As for the "invalid pointer" error, I disagree with the notion of either using a simple C-style type cast, or reinterpret_cast. Both are only workarounds to a severe problem in your code. You're only telling your compiler to shut up, but that doesn't solve the problem that is causing this! All you'd achieve is that the program compiles - and then crashes at run-time!

To properly implement this in C++, the first step is to analyze how that pointer is being used, and what data fields are supposed to be accessed via this pointer. There are two possibilities:

1. all fields being accessed are data members of struct hci_dev_list_req . If this is the case, the malloc() statement from the original code is garbage (both of them). In C++, you should declare dl as follows:
C++
std::array<hci_dev_list, HCI_MAX_DEV> dl;

There's no need for type casts, and no need for allocation or cleaning up - std::array takes care of that.

2. Some fields being accessed are not members of struct hci_dev_list_req . In this case the declaration of dl is garbage! dl is not a pointer to some struct or array of structs. Instead it's a pointer to some undefined struct which, among other things, contains hci_dev_list_req elements. And that is exactly how it should be declared. So, if the original C program does not provide the appropriate struct definition, you should create one yourself.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.