example of cdecl

hi i have to write and implement a cdecl subroutine call convention into my program, im not sure what this is, ive looked in manuals and online but i cant find anything helpful (this is my last resort), could someone explain to me and give an example of what a cdecl subroutine is? thanks :)
What class are you taking? Because cdecl is an x86 calling convention that you generally don't much need to worry about unless you're doing some low-level programming (such as programming in assembly).
http://www.angelcode.com/dev/callconv/callconv.html#cdecl
http://en.wikibooks.org/wiki/X86_Assembly/High-Level_Languages#CDECL

It may also refer to a Linux program of the same name that encodes and decodes C/C++ type declarations. But given your question, this is unlikely.

-Albatross
Last edited on
> i have to write and implement a cdecl subroutine call convention into my program


Most likely, it means write and implement functions that can be called from C code.

To write such a function, use the C linkage-specification
and restrict the and parameter types to standard-layout types (types that can be handled by C).
http://en.cppreference.com/w/cpp/language/language_linkage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
extern "C" int foo( char* cstr ) ;
extern "C" double bar( double a, double b ) ;

extern "C"
{
    int foo( char* cstr )
    {
        int v = 0 ;
        // ...
        return v ;
    }

    double bar( double a, double b )
    {
        double v = 0 ;
        // ...
        return v ;
    }
}
hi thanks for both of your replies, @TheRabbitoligist yes i am doing basic programming in x86 assembly. would it help if i show the code i have so far so you can see what i need to do exactly?
Topic archived. No new replies allowed.