I ran across this code from a statistics library. The header
source code was not available.
long double __declspec(nake d) poisson_distrib ution(int k,long
double m)
{
}
long double pdtrl(int k,long double m )
{
long double v;
if( (k < 0) || (m <= 0.0L) )
{
mtherr( "pdtrl", DOMAIN );
return( 0.0L );
}
v = k+1;
return( igamcl( v, m ) );
}
What would be the purpose of "__declspec(nak ed)" in the signature
of poisson_distrib ution()? Is this legal C syntax? Why would the
function body be empty? 6 2094
"John Smith" wrote: I ran across this code from a statistics library. The header source code was not available.
long double __declspec(nake d) poisson_distrib ution(int k,long double m) { }
At least a return statement is missing...
long double pdtrl(int k,long double m ) { long double v;
if( (k < 0) || (m <= 0.0L) ) { mtherr( "pdtrl", DOMAIN ); return( 0.0L ); } v = k+1; return( igamcl( v, m ) ); }
What would be the purpose of "__declspec(nak ed)" in the signature of poisson_distrib ution()?
from the MSDN:
For functions declared with the naked attribute, the compiler generates code
without prolog and epilog code. You can use this feature to write your own
prolog/epilog code sequences using inline assembler code. Naked functions
are particularly useful in writing virtual device drivers. http://msdn.microsoft.com/library/de...m/msmod_25.asp
Is this legal C syntax?
__declspec is not C. The rest is OK.
Why would the function body be empty?
mostly to avoid errors or to tell the compiler that an assembler
implementation exists, but in this case it will create new ones...
--
regards
John
John Smith <JS****@mail.ne t> writes: What would be the purpose of "__declspec(nak ed)" in the signature of poisson_distrib ution()? Is this legal C syntax?
__declspec is either an extension of a particular C
implementation, or it's the name of a macro. It's not standard
C.
Why would the function body be empty?
Beats me.
--
"In My Egotistical Opinion, most people's C programs should be indented six
feet downward and covered with dirt." -- Blair P. Houghton
"Ben Pfaff" wrote: John Smith writes:
What would be the purpose of "__declspec(nak ed)" in the signature of poisson_distrib ution()? Is this legal C syntax?
__declspec is either an extension of a particular C implementation, or it's the name of a macro. It's not standard C.
Why would the function body be empty?
Beats me.
(together with __declspec(nake d) it makes sense if the function is
implemented in assembler. the body is needed, since the __declspec(nake d)
modifyer [OT, extension] is not allowed on prototypes in VC... that is why I
was guessing at VC... directing to the MSDN)
--
John
"John Smith" <JS****@mail.ne t> wrote in message
news:MOKJf.3944 3$sa3.37126@pd7 tw1no... I ran across this code from a statistics library. The header source code was not available.
long double __declspec(nake d) poisson_distrib ution(int k,long double m) { } long double pdtrl(int k,long double m ) { long double v;
if( (k < 0) || (m <= 0.0L) ) { mtherr( "pdtrl", DOMAIN ); return( 0.0L ); } v = k+1; return( igamcl( v, m ) ); }
What would be the purpose of "__declspec(nak ed)" in the signature of poisson_distrib ution()?
It removes the prologue and epilogue (i.e., stack frame), allocation of
variables, and the assembly language return statement for the procedure.
This is useful for writing interrupt service routines since you can change
the type of assembly language return, or preventing variables from being
pushed onto a stack.
Is this legal C syntax?
You'll see this with Microsoft and OpenWatcom compilers.
Why would the function body be empty?
It should be thought of as a compiler modifier, like GCC's __attribute__() ,
which is setup similar to a prototype.
Rod Pemberton
"John Smith" <JS****@mail.ne t> wrote in message
news:MOKJf.3944 3$sa3.37126@pd7 tw1no... I ran across this code from a statistics library. The header source code was not available.
long double __declspec(nake d) poisson_distrib ution(int k,long double m) { } long double pdtrl(int k,long double m ) { long double v;
if( (k < 0) || (m <= 0.0L) ) { mtherr( "pdtrl", DOMAIN ); return( 0.0L ); } v = k+1; return( igamcl( v, m ) ); }
What would be the purpose of "__declspec(nak ed)" in the signature of poisson_distrib ution()? Is this legal C syntax? Why would the function body be empty?
__declspec(nake d) is some sort of compiler-specific gibberish to make C
integrate with non-C code.
It is not legal, portable ANSI C, and won't compile on another compiler.
That's not the same as saying that it is bad code.
I would guess that the empty function body is a placeholder and the real
code is not written in C.
--
Buy my book 12 Common Atheist Arguments (refuted)
$1.25 download or $6.90 paper, available www.lulu.com
On Sat, 18 Feb 2006 19:44:44 GMT, John Smith <JS****@mail.ne t> wrote: I ran across this code from a statistics library. The header source code was not available.
long double __declspec(nake d) poisson_distrib ution(int k,long double m) { } long double pdtrl(int k,long double m ) {
<snip> What would be the purpose of "__declspec(nak ed)" in the signature of poisson_distrib ution()? Is this legal C syntax? Why would the function body be empty?
As others have said, __declspec is not standard, it's an M$VC feature
perhaps adopted by some others for compatibility. In this case on that
implementation I'd bet 'naked' results in no generated code at all for
poisson_distrib ution just the entrypoint symbol, with the result that
calling that name actually results in calling (the body of) pdtr(),
which has the same parameters and return type and thus works --
assuming whatever igamcl() returns is in fact correct.
- David.Thompson1 at worldnet.att.ne t This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Red |
last post by:
In netscape bookmark files, there are lots of lines like this:
<DT><A HREF="http://www.commondreams.org/" ADD_DATE="1091500674"
LAST_CHARSET="ISO-8859-1" ID="rdf:#$uiYyb3">Common Dreams</A>
I want to eliminate the excess attributes and values to get this:
<DT><A HREF="http://www.commondreams.org/">Common Dreams</A>
I almost succeed with this:
$lines=preg_replace("{(<A HREF=\".*\")( ADD.*)(>.*</A>)}","\\1\\3",
$line);
|
by: Raymond Hettinger |
last post by:
For your amusement and edification, I'm working on a
series of Python puzzles designed to highlight areas of
the language known only to those who have read the
docs more than once.
Each of the following sections contains a code snippet
that someone, somewhere might find a little mysterious.
Your goal is to sleuth through the code, identify what
was expected versus what really happened, and to
|
by: Al Reynolds |
last post by:
Afternoon,
In an earlier thread (http://tinyurl.com/5v4aa), I described a
problem I was having which was rather bizarrely solved by
changing the line:
"inputbox.value = numq+ag-cw-cc;"
to:
"inputbox.value = numq+(ag)-(cw)-(cc);"
This was needed in IE6 but not in any other browser I tried.
|
by: William Wisnieski |
last post by:
Hello Everyone:
I'm having a very strange problem occurring with my Access 2000 database. I
call it the "mystery record."
Here's the story:
I have a query by form that returns a record set in a datasheet. The user
double clicks on a row in that datasheet and a main form (pop up) opens
bound to a table with a continuous subform bound to a query.
|
by: Mark Shelor |
last post by:
I've encountered a troublesome inconsistency in the C-language Perl
extension I've written for CPAN (Digest::SHA). The problem involves the
use of a static array within a performance-critical transform function.
When compiling under gcc on my big-endian PowerPC (Mac OS X),
declaring this array as "static" DECREASES the transform throughput by
around 5%. However, declaring it as "static" on gcc/Linux/Intel
INCREASES the throughput by...
| |
by: David Laub |
last post by:
Visual Studio .net 2003 automatically creates resx files with three entries
in them. What I don't understand is:
1) sometimes additional entries are automatically placed in the resx file,
and I don't understand what is triggering this. e.g. some of my app
specific objects wind up in the resx file auto-magically.
2) building on 1) above, these additional resources are then referenced in
the cs file InitializeComponent method, which is...
|
by: jojoba |
last post by:
Hi,
I hope this post is ok for this group.
Here's my deal:
I have two computers on my LAN at home.
One desktop. One laptop.
Both computers are wireless enabled (and wired enabled too).
I have running a fairly simple HTTP server (written in python) that i
|
by: =?Utf-8?B?U2lzbmF6?= |
last post by:
I'm having a very strange problem I can't seem to figure out and am hoping
maybe somebody has seen it before.
I get an exception "Cast string to date is invalid" with this chunk of code:
' class member
Private m_invDate As Date
' this code is not exact from the program, but essentially does the same
thing. This is were the exception occurs:
|
by: saputello |
last post by:
hello,
my web page looks good enough on every browser now, except that on IE a mystery "s." appears in the bottom left of the page! i can't for the life of me figure out where it's coming from. can anyone see it and identify its cause? you should be able to spot it by viewing the source code, right? if not, please let me know and i'll provide any additional code!
thank you very much.
|
by: henryrhenryr |
last post by:
Hi
I'm really hoping for some ideas!
I have been setting up phpmailer on my server and it was working nicely on my local server so I uploaded to my live server and tested. The mystery is that it times out.
The timeout occurs with fsockopen(). I have checked the php configuration line by line and I can't find anything in the live server setup that is different from the local which might affect it. Could gmail have black-listed my...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |