void

Casting the results of a volatile expression to void

梦想的初衷 提交于 2019-12-24 11:08:24
问题 Note: This is Not the same thing that has been asked many times. Yes I have read the many many posts about casting to void. None of those questions resulted in the answer I suspect is true here. Background info: Embedded C. This is specifically related to memory mapped volatile pointers. In other words, peripheral registers. I came across the following line in a routine that involves writing to an I2C peripheral: (void) I2C1->SR2; I2C1 is #defined as a struct * to volatile memory. So the

General programming - calling a non void method but not using value

倾然丶 夕夏残阳落幕 提交于 2019-12-24 08:15:19
问题 This is general programming, but if it makes a difference, I'm using objective-c. Suppose there's a method that returns a value, and also performs some actions, but you don't care about the value it returns, only the stuff that it does. Would you just call the method as if it was void? Or place the result in a variable and then delete it or forget about it? State your opinion, what you would do if you had this situation. 回答1: A common example of this is printf, which returns an int... but you

Array of void pointers in C

妖精的绣舞 提交于 2019-12-24 04:51:28
问题 I would like to create arrays of void pointers. # include <stdio.h> # include <stdlib.h> # include <unistd.h> int main(){ void * A[3]; void * D[3]; void * F[2]; void * G[4]; void * H[4]; void * J[3]; void * K[5]; void * L[4]; void * M[5]; A={D, H, K}; D ={A, G, H}; F ={K, L}; G={D, H, J, M}; H={A, G, L, M}; J={G, L, M}; K={A, F, H, L, M}; L={F, J, K, M}; M={G, H, J, K, L}; return 0; } The problem is the code won't compile it says: "expected expression before { token" What is wrong? I am using

In Java, is it possible to cast to void (not Void)?

有些话、适合烂在心里 提交于 2019-12-23 14:01:46
问题 Is there anything I can put in X, to make the follow work: Object o = (void) X; 回答1: void is notionally a primitive. (though most would disagree it is even that I suspect) You cannot cast an object to it. The closest you can come to this is an InvocationHandler can return null for a void method and a void method invoke()ed via reflection will return null . 回答2: Java is not C++. In Java, void is not a type, it is a placeholder that means "no return value". 回答3: No. You can set x = null; if you

In Java, is it possible to cast to void (not Void)?

你说的曾经没有我的故事 提交于 2019-12-23 14:01:35
问题 Is there anything I can put in X, to make the follow work: Object o = (void) X; 回答1: void is notionally a primitive. (though most would disagree it is even that I suspect) You cannot cast an object to it. The closest you can come to this is an InvocationHandler can return null for a void method and a void method invoke()ed via reflection will return null . 回答2: Java is not C++. In Java, void is not a type, it is a placeholder that means "no return value". 回答3: No. You can set x = null; if you

enable_if: minimal example for void member function with no arguments

喜欢而已 提交于 2019-12-23 09:30:10
问题 I am trying to get a better understanding of std::enable_if in C++11 and have been trying to write a minimal example: a class A with a member function void foo() that has different implementations based on the type T from the class template. The below code gives the desired result, but I am not understanding it fully yet. Why does version V2 work, but not V1 ? Why is the "redundant" type U required? #include <iostream> #include <type_traits> template <typename T> class A { public: A(T x) : a_

Printing values of type void*

邮差的信 提交于 2019-12-23 02:59:06
问题 In the below: int cmp (void* x, void*y) { printf("x: %s | y: %s\n", (char*) x, (char*) y); return 0; } int main(int argc, char *argv[]) { char * strings[] = {"xml", "json"}; qsort(strings, sizeof(strings), sizeof(strings[0]), cmp); } How would one see what the values of x , y are? The current approach produces gibberish such as: x: 2?|?? | y: 2?|?? 回答1: Read the documentation of qsort again. The arguments passed to your comparison function are not the objects to be compared, they are pointers

Void vs Int Functions

≯℡__Kan透↙ 提交于 2019-12-22 10:16:14
问题 What would be the different between void and int functions? When do i use which? Would void be used when just printing out a message or a variable value? like cout << value; Or would it just be text? And is int used when you actually do calculations within it? 回答1: void is used when you are not required to return anything from the function to the caller of the function. for eg. void no_return_fn() { cout<< "This function will not return anything" << endl; return; // returns nothing or void }

Is void** an acceptable type in ANSI-C?

大憨熊 提交于 2019-12-22 05:11:52
问题 I have seen a function whose prototype is: int myfunc(void** ppt) This function is called in a C file as a = myfunc(mystruct **var1); where mystruct is typedef for one of structure we have. This works without any compilation errors in MSVC6.0, But when I compile it with some other C compiler, it gives an error at the place where this function is called with error message: Argument of type mystruct ** is incompatible with parameter of type void ** The argument of myfunc() is kept as void**

Sending items in a LINQ sequence to a method that returns void

人盡茶涼 提交于 2019-12-22 03:35:24
问题 Often while I'm dealing with LINQ sequences, I want to send each item to a method returning void, avoiding a foreach loop. However, I haven't found an elegant way to do this. Today, I wrote the following code: private StreamWriter _sw; private void streamToFile(List<ErrorEntry> errors) { if (_sw == null) { _sw = new StreamWriter(Path.Combine (Path.GetDirectoryName(_targetDatabasePath), "errors.txt")); } Func<ErrorEntry, bool> writeSelector = (e) => { _sw.WriteLine(getTabDelimititedLine(e));