Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

How to create modules in C -


i have interface want able statically link modules. example, want able call functions (albeit in seperate files) called foo or match prototype, make call function in file without header in other files. dont impossible since found hack can it, want non hacked method. (the hack use nm functions , prototypes can dynamically call function). also, know can dynamic linking, however, want statically link files. ideas?

this common in writing test code. e.g., want call functions start test_. have shell script grep's through .c files , pulls out function names match test_.*. script generates test.c file contains function calls test functions.

e.g., generated program like:

int main() {    inittestcode();    testa();    testb();    testc(); } 

another way use linker tricks. linux kernel initialization. functions init code marked qualifier __init. defined in linux/init.h follows:

#define __init          __section(.init.text) __cold notrace 

this causes linker put function in section .init.text. kernel reclaim memory section after system boots.

for calling functions, each module declare initcall function other macros core_initcall(func), arch_initcall(func), et cetera (also defined in linux/init.h). these macros put pointer function linker section called .initcall.

at boot-time, kernel "walk" through .initcall section calling of pointers there. code walks through looks this:

extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[];  static void __init do_initcalls(void) {         initcall_t *fn;          (fn = __early_initcall_end; fn < __initcall_end; fn++)                 do_one_initcall(*fn);          /* make sure there no pending stuff initcall sequence */         flush_scheduled_work(); } 

the symbols __initcall_start, __initcall_end, etc. defined in linker script.

in general, linux kernel of cleverest tricks gcc pre-processor, compiler , linker possible. it's been great reference c tricks.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -