PDA

View Full Version : close() function confusion



iamjayanth
13th November 2008, 10:27
Hi masters,

I'm trying to call an ioctl from within a QWidget framework.I am able to use open fuction , and ioctl function. But when i use close function to close the device file QWidget close function getting executed instead of close function declared in unistd.h.

close() in unistd.h, and does not lie under a namespace or anything else I may use to uniquely identify it.

I have seen some one posting a thread for this problem before. The solution you people gave him was to use global namespaces , like
:: close();
I tried this solution , but only yielding segmentation fault. Can anyone give me another solution.

caduel
13th November 2008, 11:19
If you call a function f() in a context where another function of the same name is available, you have to disambiguate the two.

You do this by prefixing the function with namespace, class or whatever you have.
If you want to call a global function close() from inside a QWidget class, you have to write ::close() (assuming close is in the global namespace).

How exactly did you call close()?
You did pass a file descriptor to it?

iamjayanth
13th November 2008, 11:27
Yes ...I have passed a file descriptor to the function.
:: close(fd);

But it only yielded segmentation fault.

caduel
13th November 2008, 11:45
ok. show us more code, please.
(Have you tried a debugger to check the crash is related to that close() call?)