Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 c++, need help to print pointer value

views
     
TSnarf03
post Nov 6 2022, 04:13 AM, updated 4y ago

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


user posted image

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 ?
FlierMate11
post Nov 6 2022, 05:16 AM

New Member
*
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

They supposed to be address, but im not able to display them, look at the output window, how do i properly display them ?
*
Looks like OutputDebugStringA merely prints string (without format specifier available). To display memory address, you have to convert it to hexadecimal numbers.

For example in C:
CODE
printf("%x\r\n",&pbmpinf);

TSnarf03
post Nov 6 2022, 05:26 AM

Look at all my stars!!
*******
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.

For example in C:
CODE
printf("%x\r\n",&pbmpinf);

*
actually i tried printf, nothing visible(no error either).
CPURanger
post Nov 6 2022, 07:28 AM

Enthusiast
*****
Senior Member
889 posts

Joined: Jun 2008


QUOTE(narf03 @ Nov 6 2022, 05:26 AM)
actually i tried printf, nothing visible(no error either).
*
Try this,
sprintf(stderr, "%x\r\n",&pbmpinf);


Alternative longer,
char szMsg[32];
snprintf(szMsg, sizeof(szMsg), "%x\r\n",&pbmpinf);
OutputDebugStringA (szMsg);

Wow, still have people doing C.
Find The Way
post Nov 8 2022, 04:06 PM

Enthusiast
*****
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.
junyian
post Nov 8 2022, 10:28 PM

Casual
***
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.
TSnarf03
post Nov 9 2022, 02:58 AM

Look at all my stars!!
*******
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).

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.
*
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.

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.
junyian
post Nov 9 2022, 11:33 AM

Casual
***
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.

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.
*
That sounds like A LOT OF WORK tongue.gif
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.
TSnarf03
post Nov 9 2022, 12:27 PM

Look at all my stars!!
*******
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 tongue.gif
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.
*
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.

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.

junyian
post Nov 9 2022, 12:32 PM

Casual
***
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.

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.
*
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.
TSnarf03
post Nov 9 2022, 12:35 PM

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


QUOTE(junyian @ Nov 9 2022, 12:32 PM)
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.
*
lol now im forcing myself to learn c/c++, i think i venture into a dark area that if i cant help myself, nobody can.
Find The Way
post Nov 9 2022, 03:42 PM

Enthusiast
*****
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
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.
*
Ignore my last comment. Google result shows -> indeed has higher precedence than &.

 

Change to:
| Lo-Fi Version
0.0159sec    0.62    5 queries    GZIP Disabled
Time is now: 25th December 2025 - 01:01 AM