function

Template function passed to shared library (c++)

Bit of a thought experiment... Ingredient 1: A class in a (precompiled) shared library that has a function that takes a pointer to an object derived from ostream: void ClassName::SetDefaultStream(std::ostream *stream) Ingredient 2: My own class deriving from std::ostream, with some generic templated stream operator: class MyStream :...

How to find functions which are not executed?

Hi, I have a MS Visual Studio 2005 workspace, all C code. I want to find all the functions in that code, which are not called/executed when a certain test case is executed. What is the way to get that using 1.) MS VS 2005 itself or MSVC6.0 ? 2.) Using some other tool? -AD ...

How do I get a list of Emacs lisp non-interactive functions?

How do I get a complete list of non-interactive functions that I can use in Emacs Lisp? The interactive ones are easy enough to find in the help system, but I want a complete list of all the other functions I can use. For example concat, car, cdr, etc. (And preferably with documentation). Thanks Ed Edit: Answered thanks to Jouni. ...

self-invoking functions

Hi, when I code: var a = function() { alert("44") return function(){alert(33)} }()(); is this expression evaluated in the following order? define the function; pass its reference pointer to a a() is invoked return in a a new function pointer a() is invoked again and if so why do I have a syntax error if I do: function() ...

Objective C scope problem

I have the following Obj C function that works properly: NSString* myfunc( int x ) { NSString *myString = @"MYDATA"; return myString; } However if I add code to update a UIImage the compile fails with image1 being unknown. image1 is valid: it's set up in the .h, synthesized and that exact line of code works in a m...

Calling a obj-c method with a parameter

I've change a c-style function to an objective-c method. As a method, how do i use it? NSString* myfunc( int x ) is now: - (NSString *)myFuncWithParam:(int)x c code: myString = myfunc(x); // works obj-c code: myString = myFuncWithParam(x); // fails to compile. From one of the answers: myString = [object myF...

Obj-C methods: calling with parameters

I've been using c-style functions, but I just learned they can't see instance variables. So I was advised to convert them to methods. NSString* myfunc ( int x ) becomes: - (NSString *)myfunc:(int)x and myString = myfunc(x); becomes myString = [myString myfunc: x]; ?? This compiles with ominou...

How can a table be returned from an Oracle function without a custom type or cursor?

I am looking to return a table of results from an Oracle function. Using a cursor would be easiest, but the application I have to work this into will not accept a cursor as a return value. The alternative is to create a type (likely wrapped in a package) to go along with this function. However, it seems somewhat superfluous to create ...

passing char buffer to functions and getting the size of the buffer

Hello, I have set the buffer to size 100. I display the buffer in the main function where the buffer is declared. However, when I pass the buffer to the function and get the sizeof '4', I was thinking it should be 100, as that is the size of the buffer that I created in main. output: buffer size: 100 sizeof(buffer): 4 #inc...

What is the benefit to limiting throws allowed by a C++ function?

What is the benefit of declaring the possible exception-throws from a C++ function? In other words, what does adding the keyword throw() actually do? I've read that a function declaration such as void do_something() throw(); should guarantee that no exceptions originate from the do_something() function; however, this doesn't seem to hol...

How to import a function from a DLL made in Delphi?

Can you tell me how do i use the following functions in my C program. Delphi DLL - Exported functions : function GetCPUID (CpuCore: byte): ShortString; stdcall; function GetPartitionID(Partition : PChar): ShortString; stdcall; I don't have the source code for that DLL so I must adapt my C program to that DLL and not the other way aro...

Visual Basic - returning "this" in a function call

I have a function within a class which I would like to return the class itself however "return this" appears to be invalid in VB. I am using ASP.NET v1.1 if that makes a difference? Sample (extremely simplified) code is as follows: Public Class Cart Private sItems As String Public Function addItem(ByVal itemName As String) A...

What simple math function f(x) has these properties?

Hello, I have a little math problem. I would like to have a function with these properties: for x much bigger than 0: lim f(x) = x for x much smaller than 0: lim f(x) = 0 and f(0) = 1 (sorry, I had here f(1)=1 which was wrong!) f(x) should be monotonically increasing So the function should look somewhat like this: ^ ...

Resolving ambiguous categories in an ordered list

Let's take a concrete example and hope I can be clear. Suppose the (ordered) list of months: January < February < March < ... < December (with integers that stand for the months, zero-based), such that Jan is 0, Feb is 1, ..., Dec is 11. Now suppose I do not have access to the full names of months, and am given the followi...

Override a function call in C

I want to override certain function calls to various APIs for the sake of logging the calls, but I also might want to manipulate data before it is sent to the actual function. For example, say I use a function called getObjectName thousands of times in my source code. I want to temporarily override this function sometimes because I want...

How do you make __call() method for function calls?

Hi, I am trying to develop an application that intercepts functions. I know in class methods, you can have a __call() method for functions. I am wondering if such a thing exists for regular functions? I know there is a "function_exists" call, but then I'd have to do that everytime I call a function. I'd like an automated approach. Any h...

PHP pass function as param then call the function?

I need to pass a function as a parameter to another function and then call the passed function from withing the function...This is probably easier for me to explain in code..I basically want to do something like this: function ($functionToBeCalled) { call($functionToBeCalled,additional_params); } Is there a way to do that.. I am us...

Javascript: return function with predefined arguments

I have a function like function a (p1, p2) { /* ... */ } and in some scope want to get something like this: function b (/* no params! */) { return a (my1, my2) } where my1 and my2 are defined somehow in this scope. So I should get a parameterless function b, which when called calls a with fixed parameters my1 and my2. Now, the ques...

function pointers callbacks C

Hello, I have started to review callbacks. I found this link: http://stackoverflow.com/questions/142789/what-is-a-callback-in-c-and-how-are-they-implemented which has a good example of callback which is very similar to what we use at work. However, I have tried to get it to work, but I have many errors. #include <stdio.h> /* Is the ...

I want to know the difference between Low-level functions & Top-level functions

Charles Simonyi introduced the idea of "organizing really big software teams by creating one super duper uber programmer writing the top-level functions, while handing off the implementation of the lower-level functions to a team of grunt junior-programmers as needed. They called this position program manager." I want to know what are t...