I generate the my source code with Doxygen,
Doxygen generate void and another fucntion but it didnt generate static function although EXTRACT_STATIC is YES.
I am currently using version of the Doxygen 1.8.19and
I added top of the example.cpp file /** #file example.cpp */
I am using .c and .cpp file together. In the example.cpp file I have:
/**
*#brief ..
*#param size The application receives in this parameter the size of the required memory block.
*#retval The application must return a pointer to the allocated and zeroed-out memory block.
*/
static void* CheckVal (unsigned int size)
{
void* result = malloc (size);
assert (result != NULL);
memset (result, 0, size);
return result;
}
I couldnt see any function in doxygen index.html . Why this happened?
Related
I'm writing a kernel module that has private attributes for each probed instance. When performing different file operations, is it possible to access that private data?
The private data I'm referring to is stored using:
void platform_set_drvdata(struct platform_device *, void *);
and would like to be able to access that data from, say, a read file operation:
static ssize_t read(struct file *, char __user *, size_t , loff_t *);
I feel as though I've asked this before, but can't find the question: Is there a way to map a struct file object to a struct platform_device object (preferably without resorting to global variables)?
EDIT
I looked through the drivers/platform directory of the kernel for an example of code that had struct file_operations object that had members using per-probed instance data. The code I found seemed rather circular.
As of writing this, my platform instance data object now contains a struct file_operations fops member, which, when the open() is called I use the container_of() macro to get my instance data.
In the probe() function, I do:
static int am_probe(struct platform_device *pdev) {
struct am_instance * instance = devm_kzalloc(dev, sizeof(struct am_instance), GFP_KERNEL);
...
/* am_fops is in .rodata (and not a pointer) */
instance->fops = am_fops;
rv = register_chrdev(0, instance->device_name, &instance->fops);
...
platform_set_drvdata(pdev, instance);
...
Then, in the open() method I do this:
static int am_open(struct inode *inode, struct file *file) {
file->private_data = container_of(file->f_op, struct am_instance, fops);
return 0;
}
The above works, in that from the read() function, I can access the instance data by examining the file->private_data field with an appropriate cast.
Hello I am using dart:ffi to build an interface with my native c/c++ library.
and I needed a way to get a callback from c to dart as an example in sqlite:
int sqlite3_exec(
sqlite3*, /* An open database */
const char *sql, /* SQL to be evaluated */
int (*callback)(void*,int,char**,char**), /* Callback function */
void *, /* 1st argument to callback */
char **errmsg /* Error msg written here */
);
the third parameter in sqlite3_exec is function pointer to a callback.
so if I called this function in dart using ffi I need to pass a function pointer: and in dart:ffi Pointer class there is a function named fromFunction witch accepts a dart static function and an exceptionalReturn; but just by calling this function to get the function pointer of a dart managed function: a (sigterm) is raised and the dart code no long work in the process.
So My Question: Is there any way to get a native callback in dart, as in Python, c#, ..
Extra:
Is there any way to include dartino in a flutter project, since this ForeignDartFunction covers what I need.
I got an example to work. Hopefully you can adapt this to your case.
Example C function
EXTERNC int32_t foo(
int32_t bar,
int32_t (*callback)(void*, int32_t)
) {
return callback(nullptr, bar);
}
Dart code
First the typedefs. We need two for the native function foo and one for the Dart callback.
typedef example_foo = Int32 Function(
Int32 bar, Pointer<NativeFunction<example_callback>>);
typedef ExampleFoo = int Function(
int bar, Pointer<NativeFunction<example_callback>>);
typedef example_callback = Int32 Function(Pointer<Void>, Int32);
and the code for the callback
static int callback(Pointer<Void> ptr, int i) {
print('in callback i=$i');
return i + 1;
}
and the lookup
ExampleFoo nativeFoo =
nativeLib.lookup<NativeFunction<example_foo>>('foo').asFunction();
and, finally, use it like this:
int foo(int i) {
return nativeFoo(
i,
Pointer.fromFunction<example_callback>(callback, except),
);
}
as expected, foo(123) prints flutter: in callback i=123 and returns 124
Our C++ program has a built-in script interface and is able to run scripts in it. The scripts have access to convenience functions provided by the C++ program.
Now we would like Doxygen to create the documentation of the functions the script has access to. Such a function declaration looks like this:
void ScriptEngine::load_script(const QString &path) {
//...
/*! \fn sleep_ms(const unsigned int timeout_ms)
\brief sleeps for timeout_ms milliseconds.
\param timeout_ms
*/
(*lua)["sleep_ms"] = [](const unsigned int timeout_ms) {
//sleep(timeout_ms)
};
//more convenience functions..
//...
}
Obviously Doxygen won't include a
sleep_ms(const unsigned int timeout_ms)
into the documentation. Is there a way to to tell Doxygen to do so?
Do this:
Add the following line to your Doxyfile:
PREDEFINED = _DOXYGEN_
Make sure the ENABLE_PREPROCESSING tag in the Doxyfile is set to YES.
Put your declarations and documentation for the undeclared functions inside an #ifdef _DOXYGEN_ section.
#ifdef _DOXYGEN_
/*! \fn sleep_ms(const unsigned int timeout_ms)
\brief sleeps for timeout_ms milliseconds.
\param timeout_ms
*/
void sleep_ms(const unsigned int timeout_ms);
#endif
Don't put the above code inside a method or function such as ScriptEngine::load_script(), as you previously tried. And don't put it inside a namespace or class, unless in fact the function being declared is a member of that namespace or class.
With this method, your declarations will not create linker errors during a normal build, but will be seen by Doxygen.
See Also
http://www.doxygen.nl/manual/config.html#cfg_predefined
I have following piece of code in one of my source file under a project in CDT(eclipse).
extern "C" {
void* obj1(int size); /* alloc uninit memory */
void* obj2(int size); /* alloc cleared memory */
void* obj3(void*, int size); /* extend memory, new mem is uninit */
void obj4(void* ptr);
}
I am getting this error message "expected identifier or '(' before string constants"
i think that compiler could not recognise it and i need to supply it with some flag for this purpose.please propose solution for it.It also gives the same message for another piece of code
extern "C" { int NlvStrmatch(const char*, const char*, int);
}
I am doing a project on Log structure File system,I am mid way doing the project,Have created the inodes for the normal file and directory ,now i want to work on symbolic link.
Here is the structure for my inode.
int8_t is_active;
/* inode no. of the file */
uint16_t inode_number;
/* the most up-to-date version id */
uint8_t latest_version_id;
/* Details about the direct block */
BlockInfo direct_block[4];
/* Details about the indirect block */
BlockInfo indirect_block;
/* The type, permissions, etc. */
unsigned long inode_mode;
/* The user id */
//unsigned short uid;
/* The group id */
//unsigned short gid;
/* The number of links to the inode */
unsigned short number_of_links;
/* The size of the file, in bytes.
* If it is a directory file, this will contain the number of
* immediate children in the directory.
*
* If it is a regular file, it will contain the actual file size*/
unsigned long int file_size;
/* The number of blocks used by the inode */
unsigned long number_of_blocks;
/* The creation time of the file */
struct timeval creation_time;
/* The modification time of the file */
struct timeval modification_time;
struct timeval access_time;
Can Anybody help me in going about creating symbolic links.
A symlink is a regular file with the pathname to the target contained in it. Use a mode bit to cause the filesystem code to read the link and do the redirect on open, create, unlink, etc.