|
size in what units? LOC? bytes?
if it's LOC you could try something like this neatened up with a few macros:
long foo()
{
long start = __LINE__;
long end = __LINE__;
return end-start;
}
If it's about generated code try generating assembly / machine code listings from your source when you compile for the appropriate files and then counting opcodes and operands
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Sorry for not being specific but I meant bytes. Well actually I thought of one way that might work. I could stick the code in a function with a void parameter and return, then I could measure the length from the start to the return. If anyone has a better idea, keep in mind the method used has to work at runtime. I can't believe that no one has developed a standard method of doing this in C since it has to come up at least fairly often.
|
|
|
|
|
Xzyx987X wrote:
I can't believe that no one has developed a standard method of doing this in C since it has to come up at least fairly often.
Erh, why?, what's the use of it?
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
I also want to know ?
maybe he's confuse and want to use sizeof ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I think he actually wants to get the op code size of eg.
<code>
void foo()
{
char buffer[] = "A";
printf("%s\r\n", buffer);
}
</code>
Which translates to something like:
<code>
<br><br>
section .data
<span style="color: green">; data aligned on a 4 byte boundary.</span>
buffer db 'A', 0, 0, 0
mxyzptlk db "%s\r\n", 0, 0, 0, 0
section .text
_foo:
<span style="color: green">; Storing general registers for good measure.</span>
pushaw
<span style="color: green">; pushing arguments from right to left.</span>
push dword buffer
push dword mxyzptlk
<br>
<span style="color: green">; calling the extern function.</span>
call _printf
<br>
<span style="color: green">; Cleaning up the stack</span>
add esp, 8
<br>
</code>
which again translates to some mumbo jumbo machinecode
But besides the point that it's very hard to see the value in that information, there is the problem of buffer, and the anonymous string "%s\r\n", being declared in a data segment, and the rest of the code goes in a code segment (well, generally anyway, but the rare exceptions really shouldn't count).
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
The issue here is self modifying code. In order to pull this off correctly I need to be able to tell the size of a code block so I don't read over it's memory bounds when copying it to another location. Yes I could just figure out the size and declare it as a constant or something, but this would have nasty results if I changed the code that was being copied and forgot to update it's size.
|
|
|
|
|
Can anyone help me with this one:
I am tying to write an application that uses separate thread to communicate with the COM port. Everything is working fine but when I try to cancel the communication by using Thread::Abort() my application just freezes. What am I doing wrong?
--Nikola--
modified 7-Dec-20 21:01pm.
|
|
|
|
|
You should find a manner to cancel any pending IO on the port first, and then signal to your thread to exit. The thread will 'naturally' exit if it leaves the bottom of the function.
Just blowing off the thread will result in several problems - you migth be failing to close the port, you might be leaking memory, etc.
|
|
|
|
|
I have been trying to create a splitter pane inside a tab control but have been unsuccesful so far. Can anybody point me to simple example of splitters inside a tab control. I have seen one on code project, but its just too complicated.
a
|
|
|
|
|
|
|
Yes I've looked at that..its just too complicated for a begineer like me to understand as yet. Anything else that you might know of?
A
|
|
|
|
|
I would like to automatically launch a dialog box at start up! Where should I place the code, in the Doc or View class and which methods would be best.
Any help would be appreciated. Thanks
|
|
|
|
|
The modeless dialog needs to be a member variable, of your main window class I'd say.
Create it when the main window is created.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I have a .NET C++ compiled MDI application that is displaying discrepancy between the release and debug configurations. The application basically draws/paints a map in the client areas. I am noticing that in the debug version, the map draws fine. However, when it is run in the release mode, the map doesn't get drawn. I have added the debugging hooks in the release configuration and recompiled and notice that the map draws (behaving like the debug version - which is kind of expected). So, I am not sure where to turn - Anyone have any ideas?
Thanks-
|
|
|
|
|
hi all my dear
i want to recover Win XP dialup pass
but i cant recover it bcu its non asterisk password
plz help me to recover it
but i need a source code or a metode to recover it
plz help me
thanks & thanks
|
|
|
|
|
plz heeeeeeeeeeelp
plz
sooooon its my university project
|
|
|
|
|
Buddy
that's hacking ,if you can provide me your ubniversity project guidelines ,then i can help otherwise you have to do it by own
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
What function should I use to check if a file exists? I came across it when I didn't need it, now that I need it I can't find it. Gotta love how that works.
Thanks!
Hua-Ying
|
|
|
|
|
PathFileExists() in shlwapi.h
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
Thanks, love your signature!
Hua-Ying
|
|
|
|
|
You can also use _access() .
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks, I'll take a look at that!
Hua-Ying
|
|
|
|
|
You can also use GetFileAttributes()
You can also use CreateFile and try to open Existing
You can also use FindFirstFile
You can also use CFile
You can also use fopen
|
|
|
|
|
Hi,
I have a simple C++.net DLL test app that I am having trouble with.
The test consists of a Dialog style app which (on the press of a button) calls a function inside the DLL, which in turn attempts to open a dialog.
The dialog in the DLL does not open. The constructor is called, however the creation of the dialog returns with a minus one value. I believe this is because the runtime is looking for the dialog resource in the main app and not the dialog. I have tried multiple times to fix this, but have been unsuccessful
Can anyone help?
Below is a snippet of the code with the call to domodal. Thanks.
DLLEXPORT void PopUpaDialog(void)
{
//AFX_MANAGE_STATE(AfxGetStaticModuleState());
AfxMessageBox("Before Popping up the LVTest Dialog");
INT_PTR nResponse = 9999;
LVTest dlg;
nResponse = dlg.DoModal();
switch ( nResponse ) {
case -1:
AfxMessageBox("Dialog box could not be created!");
break;
case IDABORT:
// Do something
break;
case IDOK:
// Do something
break;
case IDCANCEL:
// Do something
break;
default:
AfxMessageBox("Default message after LVTest dialog");
break;
};
AfxMessageBox("After Popping up the Dialog");
}
|
|
|
|