
I want to print out the value of 2nd and 3rd parameters for the line number 151
They supposed to be address, but im not able to display them, look at the output window, how do i properly display them ?
c++, need help to print pointer value
|
|
Nov 6 2022, 04:13 AM, updated 4y ago
Show posts by this member only | Post
#1
|
![]() ![]() ![]() ![]() ![]() ![]() ![]()
Senior Member
4,547 posts Joined: Dec 2004 From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol |
![]() I want to print out the value of 2nd and 3rd parameters for the line number 151 They supposed to be address, but im not able to display them, look at the output window, how do i properly display them ? |
|
|
|
|
|
Nov 6 2022, 05:16 AM
Show posts by this member only | IPv6 | Post
#2
|
![]()
Validating
17 posts Joined: Oct 2022 |
QUOTE(narf03 @ Nov 6 2022, 04:13 AM) I want to print out the value of 2nd and 3rd parameters for the line number 151 Looks like OutputDebugStringA merely prints string (without format specifier available). To display memory address, you have to convert it to hexadecimal numbers.They supposed to be address, but im not able to display them, look at the output window, how do i properly display them ? For example in C: CODE printf("%x\r\n",&pbmpinf); |
|
|
Nov 6 2022, 05:26 AM
Show posts by this member only | Post
#3
|
![]() ![]() ![]() ![]() ![]() ![]() ![]()
Senior Member
4,547 posts Joined: Dec 2004 From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol |
QUOTE(FlierMate11 @ Nov 6 2022, 05:16 AM) Looks like OutputDebugStringA merely prints string (without format specifier available). To display memory address, you have to convert it to hexadecimal numbers. actually i tried printf, nothing visible(no error either).For example in C: CODE printf("%x\r\n",&pbmpinf); |
|
|
Nov 6 2022, 07:28 AM
Show posts by this member only | Post
#4
|
![]() ![]() ![]() ![]() ![]()
Senior Member
889 posts Joined: Jun 2008 |
|
|
|
Nov 8 2022, 04:06 PM
Show posts by this member only | IPv6 | Post
#5
|
![]() ![]() ![]() ![]() ![]()
Senior Member
724 posts Joined: Nov 2004 |
To get the address of that PBitmapInfo, have you try
CODE &(pFrameData->PBitmapInfo) , rather than CODE &pFrameData->PBitmapInfo ?I haven't touch C++ for more than a decade, I might have got the operator precedence wrongly. |
|
|
Nov 8 2022, 10:28 PM
Show posts by this member only | Post
#6
|
![]() ![]() ![]()
Junior Member
401 posts Joined: Jan 2003 |
What's the definition of PBitmapInfo and PBitmapBits? If these are addresses (or pointers), then you should use be using printf("%x", pFrameData->PBitmapInfo).
Using &pFrameData->PBitmapInfo would mean, "address of pFrameData->PBitmapInfo", i.e. address of an address. *pFrameData->PBitmapInfo would then be "content of pFrameData->PBitmapInfo". Or just save your headache and use a debugger, put a breakpoint on that line, and see the value in memory. |
|
|
|
|
|
Nov 9 2022, 02:58 AM
Show posts by this member only | Post
#7
|
![]() ![]() ![]() ![]() ![]() ![]() ![]()
Senior Member
4,547 posts Joined: Dec 2004 From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol |
QUOTE(junyian @ Nov 8 2022, 10:28 PM) What's the definition of PBitmapInfo and PBitmapBits? If these are addresses (or pointers), then you should use be using printf("%x", pFrameData->PBitmapInfo). ya, im backing off, what i was doing is making dll and plug into unity, dll do not really give you error, it will just crash, i think i need to do 1 step at a time.Using &pFrameData->PBitmapInfo would mean, "address of pFrameData->PBitmapInfo", i.e. address of an address. *pFrameData->PBitmapInfo would then be "content of pFrameData->PBitmapInfo". Or just save your headache and use a debugger, put a breakpoint on that line, and see the value in memory. whole picture is, i want to use capture card sdk, capture bitmap(the question you ask what are those, they are pointer returned by a capture call back after 1 frame has been captured), then in unity, what supposed to happen is call the dll, unity create texture, pass texture reference into c++ native dll, then the native dll fill the texture with bitmap data(using opengl). Why doing it outside unity ? cause we can only use main thread to do certain things, and i want the capture to happen as fast as possible, so it need to be offload to other thread, and that can only work outside unity. |
|
|
Nov 9 2022, 11:33 AM
Show posts by this member only | Post
#8
|
![]() ![]() ![]()
Junior Member
401 posts Joined: Jan 2003 |
QUOTE(narf03 @ Nov 9 2022, 02:58 AM) ya, im backing off, what i was doing is making dll and plug into unity, dll do not really give you error, it will just crash, i think i need to do 1 step at a time. That sounds like A LOT OF WORK whole picture is, i want to use capture card sdk, capture bitmap(the question you ask what are those, they are pointer returned by a capture call back after 1 frame has been captured), then in unity, what supposed to happen is call the dll, unity create texture, pass texture reference into c++ native dll, then the native dll fill the texture with bitmap data(using opengl). Why doing it outside unity ? cause we can only use main thread to do certain things, and i want the capture to happen as fast as possible, so it need to be offload to other thread, and that can only work outside unity. I imagine there will be crap loads of bitmaps that will be captured. It might take up a lot of resources just to dump out the data. Anyway, if you're doing a dll, the only option probably is to write to external files. I did something similar to debug something - modified and custom compiled Python's core dll to dump Python opcodes to a separate file. If I'm not mistaken, DLLs can't spin off consoles to print data. |
|
|
Nov 9 2022, 12:27 PM
Show posts by this member only | Post
#9
|
![]() ![]() ![]() ![]() ![]() ![]() ![]()
Senior Member
4,547 posts Joined: Dec 2004 From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol |
QUOTE(junyian @ Nov 9 2022, 11:33 AM) That sounds like A LOT OF WORK nope, file base not acceptable. technically i have done something similar but capture bmp in external desktop app, use socket pass them into unity(within same pc), then unity upload to gpu (means convert to texture) in the main thread, the maximum it can go is around 200 FullHD(32bit) bitmap per second, bandwidth wise is 1920x1080x4(32bit to 4 byte)x200 bmp = 1.65 gigabyte per second.I imagine there will be crap loads of bitmaps that will be captured. It might take up a lot of resources just to dump out the data. Anyway, if you're doing a dll, the only option probably is to write to external files. I did something similar to debug something - modified and custom compiled Python's core dll to dump Python opcodes to a separate file. If I'm not mistaken, DLLs can't spin off consoles to print data. normal hdd cant write that much per second, and if use SSD, the SSD will die within a year or so(cause SSD have limited writes per cell), and i am trying to see if i use multithread, wanna push that limit to another few times higher. PCIE 4.0x16 bandwidth is ~32Gigabyte per second. i am not greedy, if can achieve 10GB(~1200 full hd bmp per second), im very happy d. |
|
|
Nov 9 2022, 12:32 PM
|
![]() ![]() ![]()
Junior Member
401 posts Joined: Jan 2003 |
QUOTE(narf03 @ Nov 9 2022, 12:27 PM) nope, file base not acceptable. technically i have done something similar but capture bmp in external desktop app, use socket pass them into unity(within same pc), then unity upload to gpu (means convert to texture) in the main thread, the maximum it can go is around 200 FullHD(32bit) bitmap per second, bandwidth wise is 1920x1080x4(32bit to 4 byte)x200 bmp = 1.65 gigabyte per second. Oooh.. very interesting approach! I haven't studied much how on how to use gpu (nor unity). That will definitely go into my to-study list.normal hdd cant write that much per second, and if use SSD, the SSD will die within a year or so(cause SSD have limited writes per cell), and i am trying to see if i use multithread, wanna push that limit to another few times higher. PCIE 4.0x16 bandwidth is ~32Gigabyte per second. i am not greedy, if can achieve 10GB(~1200 full hd bmp per second), im very happy d. |
|
|
Nov 9 2022, 12:35 PM
|
![]() ![]() ![]() ![]() ![]() ![]() ![]()
Senior Member
4,547 posts Joined: Dec 2004 From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol |
|
|
|
Nov 9 2022, 03:42 PM
|
![]() ![]() ![]() ![]() ![]()
Senior Member
724 posts Joined: Nov 2004 |
QUOTE(Find The Way @ Nov 8 2022, 04:06 PM) To get the address of that PBitmapInfo, have you try Ignore my last comment. Google result shows -> indeed has higher precedence than &.CODE &(pFrameData->PBitmapInfo) , rather than CODE &pFrameData->PBitmapInfo ?I haven't touch C++ for more than a decade, I might have got the operator precedence wrongly. junyian liked this post
|
| Change to: | 0.0148sec
1.46
5 queries
GZIP Disabled
Time is now: 24th December 2025 - 10:58 PM |