Search Results

Search found 48020 results on 1921 pages for 'void return'.

Page 1/1921 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Why does void in C mean not void?

    - by Naftuli Tzvi Kay
    In strongly-typed languages like Java and C#, void (or Void) as a return type for a method seem to mean: This method doesn't return anything. Nothing. No return. You will not receive anything from this method. What's really strange is that in C, void as a return type or even as a method parameter type means: It could really be anything. You'd have to read the source code to find out. Good luck. If it's a pointer, you should really know what you're doing. Consider the following examples in C: void describe(void *thing) { Object *obj = thing; printf("%s.\n", obj->description); } void *move(void *location, Direction direction) { void *next = NULL; // logic! return next; } Obviously, the second method returns a pointer, which by definition could be anything. Since C is older than Java and C#, why did these languages adopt void as meaning "nothing" while C used it as "nothing or anything (when a pointer)"?

    Read the article

  • How to implement an interface member that returns void in F#

    - by Drew Noakes
    Imagine the following interface in C#: interface IFoo { void Bar(); } How can I implement this in F#? All the examples I've found during 30 minutes of searching online show only examples that have return types which I suppose is more common in a functional style, but something I can't avoid in this instance. Here's what I have so far: type Bar() = interface IFoo with member this.Bar = void Fails with FS0010: Unexpected keyword 'void' in expression.

    Read the article

  • What does this mean: warning: converting from ‘void (ClassName::*)()’ to ‘void (*)()’

    - by Brendan Long
    I have a member function in a class that has a callback, but the callback isn't strictly neccessary, so it has a default callback, which is empty. It seems to work fine, but I get an annoying warning: warning: converting from ‘void (ClassName::*)()’ to ‘void (*)()’ I'm trying to figure out what it means and how to turn it off (or fix it if I really am doing something wrong). Here's some simple code: class ClassName{ public: void doSomething(void (*callbackFunction)() = (void(*)()) &ClassName::doNothing){ callbackFunction(); } void doNothing(){} }; int main(){ ClassName x; x.doSomething(); return 0; } Note: If I do this (without explicitly casting it as a void(*)()): void doSomething(void (*callbackFunction)() = &ClassName::doNothing) I get this: main.cpp:3: error: default argument for parameter of type ‘void (*)()’ has type ‘void (ClassName::*)()’

    Read the article

  • C# return variables

    - by pb01
    In a debate regarding return variables, some members of the team prefer a method to return the result directly to the caller, whereas others prefer to declare a return variable that is then returned to the caller (see code examples below) The argument for the latter is that it allows a developer that is debugging the code to find the return value of the method before it returns to the caller thereby making the code easier to understand: This is especially true where method calls are daisy-chained. Are there any guidelines as to which is the most efficient and/or are there any other reasons why we should adopt one style over another? Thanks private bool Is2(int a) { return a == 2; } private bool Is3(int a) { var result = a == 3; return result; }

    Read the article

  • How to use void*

    - by Rondogiannis Aristophanes
    I am imlementing a simple merge function and I have got stuck, as the compiler gives me errors that I cannot explain. Here is my merge function: void merge(void *a, int beg, int middle, int end, int (*cmp)(const void*, const void* { std::stack<void*> first; std::stack<void*> second; for(int i = beg; i < middle; i++) { first.push(a+i); } for(int i = middle; i < end; i++) { second.push(a+i); } for(int i = beg; i < end; i++) { if(first.empty()) { void *tmp = second.top(); second.pop(); a+i = tmp; } else if(second.empty()) { void *tmp = first.top(); first.pop(); a+i = tmp; } else if(cmp(first.top(), second.top())) { void *tmp = first.top(); first.pop(); a+i = tmp; } else { void *tmp = second.top(); second.pop(); a+i = tmp; } } } And here is the error: sort.h: In function `void merge(void*, int, int, int, int (*)(const void*, const void*))': sort.h:9: error: pointer of type `void *' used in arithmetic sort.h:12: error: pointer of type `void *' used in arithmetic sort.h:19: error: pointer of type `void *' used in arithmetic sort.h:19: error: non-lvalue in assignment sort.h:23: error: pointer of type `void *' used in arithmetic sort.h:23: error: non-lvalue in assignment sort.h:27: error: pointer of type `void *' used in arithmetic sort.h:27: error: non-lvalue in assignment sort.h:31: error: pointer of type `void *' used in arithmetic sort.h:31: error: non-lvalue in assignment Can anyone help me? TIA.

    Read the article

  • What do I return if the return type of a method is Void? (Not void!)

    - by DR
    Due to the use of Generics in Java I ended up in having to implement a function having Void as return type: public Void doSomething() { //... } and the compiler demands that I return something. For now I'm just returning null, but I'm wondering if that is good coding practice... I've also tried Void.class, void, Void.TYPE, new Void(), no return at all, but all that doesn't work at all. (For more or less obvious reasons) (See this answer for details) So what am I supposed to return if the return type of a function is Void? What's the general use of the Void class? EDIT: Just to spare you the downvotes: I'm asking about V?oid, not v?oid. The class Void, not the reserved keyword void.

    Read the article

  • " not all code paths return a value" when return enum type

    - by netmajor
    I have enum list and method and i get error: " not all code paths return a value" Some idea whats wrong in my method ? I am sure I always return STANY type :/ Thanks for help :) private enum STANY { PATROL, CHAT, EAT, SEARCH, DIE }; private STANY giveState(int id, List<Ludek> gracze, List<int> plansza) { // Sprawdz czy gracz stoi na polu z jedzeniem i nie ma 2000 jednostek jedzenia bool onTheFood = false; onTheFood = CzyPoleZjedzeniem(id, gracze, plansza, onTheFood); if (onTheFood && (gracze[id].IloscJedzenia < startFood / 2)) return STANY.EAT; // Sprawdz czy gracz nie stoi na polu z innym graczem bool allKnowledge = true; allKnowledge = CzyPoleZInnymGraczem(id, gracze, allKnowledge); if (!allKnowledge) return STANY.CHAT; // Jesli ma ponad i rowna ilosc jedzenia patroluj if (gracze[id].IloscJedzenia >= startFood / 2) return STANY.PATROL; // Jesli ma mniej niz polowe jedzenia szukaj jedzenia if (gracze[id].IloscJedzenia > 0 && gracze[id].IloscJedzenia < startFood / 2) return STANY.SEARCH; // Jesli nie ma jedzenia umieraj if (gracze[id].IloscJedzenia <= 0) return STANY.DIE; }

    Read the article

  • See return value in C#

    - by Snake
    Hi, Consider the following piece of code: As you can see we are on line 28. Is there any way to see the return value of the function at this point, without letting the code return to the caller function? Foo.Bar() is a function call which generates a unique path (for example). So it's NOT constant. In VB.NET it's possible by entering the function's name in the Watch, which will then threat it as a variable. But in C# this is not possible, any other tips? PS: rewriting is not an option.

    Read the article

  • Is conditional return type ever a good idea?

    - by qegal
    So I have a method that's something like this: -(BOOL)isSingleValueRecord And another method like this: -(Type)typeOfSingleValueRecord And it occurred to me that I could combine them into something like this: -(id)isSingleValueRecord And have the implementation be something like this: -(id)isSingleValueRecord { //If it is single value if(self.recordValue = 0) { //Do some stuff to determine type, then return it return typeOfSingleValueRecord; } //If its not single value else { //Return "NO" return [NSNumber numberWithBool:NO]; } } So combining the two methods makes it more efficient but makes the readability go down. In my gut, I feel like I should go with the two-method version, but is that really right? Is there any case that I should go with the combined version?

    Read the article

  • Proper way to return an array

    - by Ward
    Hey there, I never seem to get this right. I've got a method that returns a mutable array. What is the proper way to return the array and avoid potential memory leaks? If I plan to store the results locally inside another view controller, does that affect the way the array should be returned? Lastly, what if it's just an non-mutable array? Does that require a different technique? thanks, Howie

    Read the article

  • Return value from ajax call?

    - by Dan
    Hi, I'm making a basic ajax function in jquery which echoes the number of rows found in a MySQL Query. function checkEventIDClass(id) { var params = 'method=checkEventIDClash&table=test&id=' + id; $.ajax({ type: "POST", url: "ajax.php", data: params, success: function(result){ return result; } }); } Is it possible to use this returned value in another function? I have tried but only get undefined values. In this situation, it will be acceptable to use synchronous calls. Any advice appreciated. Thanks

    Read the article

  • Naming methods that do the same thing but return different types

    - by Konstantin Ð.
    Let's assume that I'm extending a graphical file chooser class (JFileChooser). This class has methods which display the file chooser dialog and return a status signature in the form of an int: APPROVE_OPTION if the user selects a file and hits Open /Save, CANCEL_OPTION if the user hits Cancel, and ERROR_OPTION if something goes wrong. These methods are called showDialog(). I find this cumbersome, so I decide to make another method that returns a File object: in the case of APPROVE_OPTION, it returns the file selected by the user; otherwise, it returns null. This is where I run into a problem: would it be okay for me to keep the showDialog() name, even though methods with that name — and a different return type — already exist? To top it off, my method takes an additional parameter: a File which denotes in which directory the file chooser should start. My question to you: Is it okay to call a method the same name as a superclass method if they return different types? Or would that be confusing to API users? (If so, what other name could I use?) Alternatively, should I keep the name and change the return type so it matches that of the other methods? public int showDialog(Component parent, String approveButtonText) // Superclass method public File showDialog(Component parent, File location) // My method

    Read the article

  • eventmachine on debian fails install via rubygems

    - by Max
    this has been killing me for the last 5 hours. I don't seem to be able to get eventmachine running on my debian box. here this output: $ gem install thin Building native extensions. This could take a while... ERROR: Error installing thin: ERROR: Failed to build gem native extension. /home/eventhub/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb checking for rb_trap_immediate in ruby.h,rubysig.h... no checking for rb_thread_blocking_region()... yes checking for inotify_init() in sys/inotify.h... yes checking for writev() in sys/uio.h... yes checking for rb_wait_for_single_fd()... yes checking for rb_enable_interrupt()... yes checking for rb_time_new()... yes checking for sys/event.h... no checking for epoll_create() in sys/epoll.h... yes creating Makefile make compiling kb.cpp cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++ cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++ In file included from project.h:149, from kb.cpp:20: binder.h:35: warning: type qualifiers ignored on function return type In file included from project.h:150, from kb.cpp:20: em.h:84: warning: type qualifiers ignored on function return type em.h:85: warning: type qualifiers ignored on function return type em.h:86: warning: type qualifiers ignored on function return type em.h:88: warning: type qualifiers ignored on function return type em.h:89: warning: type qualifiers ignored on function return type em.h:90: warning: type qualifiers ignored on function return type em.h:91: warning: type qualifiers ignored on function return type em.h:93: warning: type qualifiers ignored on function return type em.h:99: warning: type qualifiers ignored on function return type em.h:116: warning: type qualifiers ignored on function return type em.h:125: warning: type qualifiers ignored on function return type In file included from project.h:154, from kb.cpp:20: eventmachine.h:46: warning: type qualifiers ignored on function return type eventmachine.h:47: warning: type qualifiers ignored on function return type eventmachine.h:48: warning: type qualifiers ignored on function return type eventmachine.h:50: warning: type qualifiers ignored on function return type eventmachine.h:65: warning: type qualifiers ignored on function return type eventmachine.h:66: warning: type qualifiers ignored on function return type eventmachine.h:67: warning: type qualifiers ignored on function return type eventmachine.h:68: warning: type qualifiers ignored on function return type In file included from project.h:154, from kb.cpp:20: eventmachine.h:103: warning: type qualifiers ignored on function return type eventmachine.h:105: warning: type qualifiers ignored on function return type eventmachine.h:108: warning: type qualifiers ignored on function return type compiling rubymain.cpp cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++ cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++ In file included from project.h:149, from rubymain.cpp:20: binder.h:35: warning: type qualifiers ignored on function return type In file included from project.h:150, from rubymain.cpp:20: em.h:84: warning: type qualifiers ignored on function return type em.h:85: warning: type qualifiers ignored on function return type em.h:86: warning: type qualifiers ignored on function return type em.h:88: warning: type qualifiers ignored on function return type em.h:89: warning: type qualifiers ignored on function return type em.h:90: warning: type qualifiers ignored on function return type em.h:91: warning: type qualifiers ignored on function return type em.h:93: warning: type qualifiers ignored on function return type em.h:99: warning: type qualifiers ignored on function return type em.h:116: warning: type qualifiers ignored on function return type em.h:125: warning: type qualifiers ignored on function return type In file included from project.h:154, from rubymain.cpp:20: eventmachine.h:46: warning: type qualifiers ignored on function return type eventmachine.h:47: warning: type qualifiers ignored on function return type eventmachine.h:48: warning: type qualifiers ignored on function return type eventmachine.h:50: warning: type qualifiers ignored on function return type eventmachine.h:65: warning: type qualifiers ignored on function return type eventmachine.h:66: warning: type qualifiers ignored on function return type eventmachine.h:67: warning: type qualifiers ignored on function return type eventmachine.h:68: warning: type qualifiers ignored on function return type In file included from project.h:154, from rubymain.cpp:20: eventmachine.h:103: warning: type qualifiers ignored on function return type eventmachine.h:105: warning: type qualifiers ignored on function return type eventmachine.h:108: warning: type qualifiers ignored on function return type compiling ssl.cpp cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++ cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++ In file included from project.h:149, from ssl.cpp:23: binder.h:35: warning: type qualifiers ignored on function return type In file included from project.h:150, from ssl.cpp:23: em.h:84: warning: type qualifiers ignored on function return type em.h:85: warning: type qualifiers ignored on function return type em.h:86: warning: type qualifiers ignored on function return type em.h:88: warning: type qualifiers ignored on function return type em.h:89: warning: type qualifiers ignored on function return type em.h:90: warning: type qualifiers ignored on function return type em.h:91: warning: type qualifiers ignored on function return type em.h:93: warning: type qualifiers ignored on function return type em.h:99: warning: type qualifiers ignored on function return type em.h:116: warning: type qualifiers ignored on function return type em.h:125: warning: type qualifiers ignored on function return type In file included from project.h:154, from ssl.cpp:23: eventmachine.h:46: warning: type qualifiers ignored on function return type eventmachine.h:47: warning: type qualifiers ignored on function return type eventmachine.h:48: warning: type qualifiers ignored on function return type eventmachine.h:50: warning: type qualifiers ignored on function return type eventmachine.h:65: warning: type qualifiers ignored on function return type eventmachine.h:66: warning: type qualifiers ignored on function return type eventmachine.h:67: warning: type qualifiers ignored on function return type eventmachine.h:68: warning: type qualifiers ignored on function return type In file included from project.h:154, from ssl.cpp:23: eventmachine.h:103: warning: type qualifiers ignored on function return type eventmachine.h:105: warning: type qualifiers ignored on function return type eventmachine.h:108: warning: type qualifiers ignored on function return type compiling cmain.cpp cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++ cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++ In file included from project.h:149, from cmain.cpp:20: binder.h:35: warning: type qualifiers ignored on function return type In file included from project.h:150, from cmain.cpp:20: em.h:84: warning: type qualifiers ignored on function return type em.h:85: warning: type qualifiers ignored on function return type em.h:86: warning: type qualifiers ignored on function return type em.h:88: warning: type qualifiers ignored on function return type em.h:89: warning: type qualifiers ignored on function return type em.h:90: warning: type qualifiers ignored on function return type em.h:91: warning: type qualifiers ignored on function return type em.h:93: warning: type qualifiers ignored on function return type em.h:99: warning: type qualifiers ignored on function return type em.h:116: warning: type qualifiers ignored on function return type em.h:125: warning: type qualifiers ignored on function return type In file included from project.h:154, from cmain.cpp:20: eventmachine.h:46: warning: type qualifiers ignored on function return type eventmachine.h:47: warning: type qualifiers ignored on function return type eventmachine.h:48: warning: type qualifiers ignored on function return type eventmachine.h:50: warning: type qualifiers ignored on function return type eventmachine.h:65: warning: type qualifiers ignored on function return type eventmachine.h:66: warning: type qualifiers ignored on function return type eventmachine.h:67: warning: type qualifiers ignored on function return type eventmachine.h:68: warning: type qualifiers ignored on function return type In file included from project.h:154, from cmain.cpp:20: eventmachine.h:103: warning: type qualifiers ignored on function return type eventmachine.h:105: warning: type qualifiers ignored on function return type eventmachine.h:108: warning: type qualifiers ignored on function return type cmain.cpp:96: warning: type qualifiers ignored on function return type cmain.cpp:107: warning: type qualifiers ignored on function return type cmain.cpp:117: warning: type qualifiers ignored on function return type cmain.cpp:127: warning: type qualifiers ignored on function return type cmain.cpp:269: warning: type qualifiers ignored on function return type cmain.cpp:279: warning: type qualifiers ignored on function return type cmain.cpp:289: warning: type qualifiers ignored on function return type cmain.cpp:299: warning: type qualifiers ignored on function return type cmain.cpp:309: warning: type qualifiers ignored on function return type cmain.cpp:329: warning: type qualifiers ignored on function return type cmain.cpp:678: warning: type qualifiers ignored on function return type compiling em.cpp cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++ cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++ In file included from project.h:149, from em.cpp:23: binder.h:35: warning: type qualifiers ignored on function return type In file included from project.h:150, from em.cpp:23: em.h:84: warning: type qualifiers ignored on function return type em.h:85: warning: type qualifiers ignored on function return type em.h:86: warning: type qualifiers ignored on function return type em.h:88: warning: type qualifiers ignored on function return type em.h:89: warning: type qualifiers ignored on function return type em.h:90: warning: type qualifiers ignored on function return type em.h:91: warning: type qualifiers ignored on function return type em.h:93: warning: type qualifiers ignored on function return type em.h:99: warning: type qualifiers ignored on function return type em.h:116: warning: type qualifiers ignored on function return type em.h:125: warning: type qualifiers ignored on function return type In file included from project.h:154, from em.cpp:23: eventmachine.h:46: warning: type qualifiers ignored on function return type eventmachine.h:47: warning: type qualifiers ignored on function return type eventmachine.h:48: warning: type qualifiers ignored on function return type eventmachine.h:50: warning: type qualifiers ignored on function return type eventmachine.h:65: warning: type qualifiers ignored on function return type eventmachine.h:66: warning: type qualifiers ignored on function return type eventmachine.h:67: warning: type qualifiers ignored on function return type eventmachine.h:68: warning: type qualifiers ignored on function return type In file included from project.h:154, from em.cpp:23: eventmachine.h:103: warning: type qualifiers ignored on function return type eventmachine.h:105: warning: type qualifiers ignored on function return type eventmachine.h:108: warning: type qualifiers ignored on function return type em.cpp: In member function 'bool EventMachine_t::_RunEpollOnce()': em.cpp:578: warning: 'int rb_thread_select(int, fd_set*, fd_set*, fd_set*, timeval*)' is deprecated (declared at /home/eventhub/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:379) em.cpp:578: warning: 'int rb_thread_select(int, fd_set*, fd_set*, fd_set*, timeval*)' is deprecated (declared at /home/eventhub/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:379) em.cpp: In member function 'bool EventMachine_t::_RunSelectOnce()': em.cpp:974: warning: 'int rb_thread_select(int, fd_set*, fd_set*, fd_set*, timeval*)' is deprecated (declared at /home/eventhub/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:379) em.cpp:974: warning: 'int rb_thread_select(int, fd_set*, fd_set*, fd_set*, timeval*)' is deprecated (declared at /home/eventhub/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:379) em.cpp: At global scope: em.cpp:1057: warning: type qualifiers ignored on function return type em.cpp:1079: warning: type qualifiers ignored on function return type em.cpp:1265: warning: type qualifiers ignored on function return type em.cpp:1338: warning: type qualifiers ignored on function return type em.cpp:1510: warning: type qualifiers ignored on function return type em.cpp:1593: warning: type qualifiers ignored on function return type em.cpp:1856: warning: type qualifiers ignored on function return type em.cpp:1982: warning: type qualifiers ignored on function return type em.cpp:2046: warning: type qualifiers ignored on function return type em.cpp:2070: warning: type qualifiers ignored on function return type em.cpp:2142: warning: type qualifiers ignored on function return type em.cpp:2361: fatal error: error writing to /tmp/ccdlOK0T.s: No space left on device compilation terminated. make: *** [em.o] Error 1 Gem files will remain installed in /home/eventhub/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-1.0.1 for inspection. Results logged to /home/eventhub/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-1.0.1/ext/gem_make.out Any thoughts? I read a lot of different ways to solve this issue, but none of them worked. Thanks

    Read the article

  • -(void)... does not work/appeal (iOS)

    - by user1012535
    Hi I've got a problem with my -(void) in my Xcode project for iOS. First of all here is the code ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController { IBOutlet UIWebView *webview; IBOutlet UIActivityIndicatorView *active; UIAlertView *alert_start; UIAlertView *alert_error; } -(IBAction)tele_button:(id)sender; -(IBAction)mail_button:(id)sender; -(IBAction)web_button:(id)sender; -(IBAction)news_button:(id)sender; @end ViewController.m #import "ViewController.h" @implementation ViewController - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; //Stop Bounce for WebView for (id subview in webview.subviews) if ([[subview class] isSubclassOfClass: [UIScrollView class]]) ((UIScrollView *)subview).bounces = NO; //First Start Alert [alert_start show]; NSLog(@"first alert"); NSString *start_alert = [[NSUserDefaults standardUserDefaults] objectForKey:@"alert_start"]; if(start_alert == nil) { [[NSUserDefaults standardUserDefaults] setValue:@"1" forKey:@"alert_start"]; [[NSUserDefaults standardUserDefaults] synchronize]; UIAlertView *alert_start = [[UIAlertView alloc] initWithTitle:@"iOptibelt" message:@"On some points this application need a internet connection." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert_start show]; [alert_start release]; } // Do any additional setup after loading the view, typically from a nib. [webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"home-de" ofType:@"html"]isDirectory:NO]]]; NSLog(@"webview fertig"); } -(void)webViewDidStartLoad:(UIWebView *) webview { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; [active startAnimating]; NSLog(@"lade"); } -(void)webViewDidFinishLoad:(UIWebView *) webview { [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [active stopAnimating]; NSLog(@"fertig"); } -(void)webView: (UIWebView *) webview didFailLoadWithError:(NSError *)error{ NSLog(@"lade error"); UIAlertView *alert_error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert_error show]; [alert_error release]; }; - (IBAction)tele_button:(id)sender{ NSLog(@"it's connected!"); //Local HTML Call Button NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"phone" ofType:@"html"]isDirectory:NO]]; [webview loadRequest:theRequest]; } - (IBAction)mail_button:(id)sender{ NSLog(@"it's connected!"); //Mail App Mail Button [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://[email protected]"]]; } - (IBAction)web_button:(id)sender{ NSLog(@"it's connected!"); //Local HTML Button NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString: @"http://optibelt.com"]]; [webview loadRequest:theRequest]; } - (IBAction)news_button:(id)sender{ NSLog(@"it's connected!"); //local Home Button NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"home-de" ofType:@"html"]isDirectory:NO]]; [webview loadRequest:theRequest]; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } @end At last my 3. -(void) does not work and i ve no more idea what could be the problem.... -(void)webViewDidStartLoad:(UIWebView *) webview { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; [active startAnimating]; NSLog(@"lade"); } -(void)webViewDidFinishLoad:(UIWebView *) webview { [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [active stopAnimating]; NSLog(@"fertig"); } -(void)webView: (UIWebView *) webview didFailLoadWithError:(NSError *)error{ NSLog(@"lade error"); UIAlertView *alert_error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert_error show]; [alert_error release];

    Read the article

  • Void in main and keeping Dos program from dying

    - by TimothyTech
    Alright, so im using bloodshed complier, first thing i should note is im using a 2001 edition C++ for the aboslute beginner, was there any changes to C++ since 2001 that would effect the validity of this book? i ask because i know php has php5 and now php6 but i havent seen any C++3. now for the reason i asked that, in this code it uses, void main (void) why would i want an arguement to be void? what does this do. But when i run the " void main (void) in my compiler it says that main must have a "int" before it. so i cant have "void" main (void); also, once the code runs through, as long as there isnt a "cin" the program closes. is this normal behavior, is there a better way to stop this besides making a cin at the end of my program.

    Read the article

  • Void pointers in C

    - by avd
    I have written this qsort: void qsort(void *a[],int low,int high, int (*compare)(void*,void*)); When I call this on char *strarr[5]; It says invalid conversion from char** to void**. Why this is wrong? This is the code:http://codepad.org/Flfm2zAE

    Read the article

  • How to get rid of void-pointers.

    - by Patrick
    I inherited a big application that was originally written in C (but in the mean time a lot of C++ was also added to it). Because of historical reasons, the application contains a lot of void-pointers. Before you start to choke, let me explain why this was done. The application contains many different data structures, but they are stored in 'generic' containers. Nowadays I would use templated STL containers for it, or I would give all data structures a common base class, so that the container can store pointers to the base class, but in the [good?] old C days, the only solution was to cast the struct-pointer to a void-pointer. Additionally, there is a lot of code that works on these void-pointers, and uses very strange C constructions to emulate polymorphism in C. I am now reworking the application, and trying to get rid of the void-pointers. Adding a common base-class to all the data structures isn't that hard (few days of work), but the problem is that the code is full of constructions like shown below. This is an example of how data is stored: void storeData (int datatype, void *data); // function prototype ... Customer *myCustomer = ...; storeData (TYPE_CUSTOMER, myCustomer); This is an example of how data is fetched again: Customer *myCustomer = (Customer *) fetchData (int datatype, char *key); I actually want to replace all the void-pointers with some smart-pointer (reference-counted), but I can't find a trick to automate (or at least) help me to get rid of all the casts to and from void-pointers. Any tips on how to find, replace, or interact in any possible way with these conversions?

    Read the article

  • What to Return? Error String, Bool with Error String Out, or Void with Exception

    - by Ranger Pretzel
    I spend most of my time in C# and am trying to figure out which is the best practice for handling an exception and cleanly return an error message from a called method back to the calling method. For example, here is some ActiveDirectory authentication code. Please imagine this Method as part of a Class (and not just a standalone function.) bool IsUserAuthenticated(string domain, string user, string pass, out errStr) { bool authentic = false; try { // Instantiate Directory Entry object DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain, user, pass); // Force connection over network to authenticate object nativeObject = entry.NativeObject; // No exception thrown? We must be good, then. authentic = true; } catch (Exception e) { errStr = e.Message().ToString(); } return authentic; } The advantages of doing it this way are a clear YES or NO that you can embed right in your If-Then-Else statement. The downside is that it also requires the person using the method to supply a string to get the Error back (if any.) I guess I could overload this method with the same parameters minus the "out errStr", but ignoring the error seems like a bad idea since there can be many reasons for such a failure... Alternatively, I could write a method that returns an Error String (instead of using "out errStr") in which a returned empty string means that the user authenticated fine. string AuthenticateUser(string domain, string user, string pass) { string errStr = ""; try { // Instantiate Directory Entry object DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain, user, pass); // Force connection over network to authenticate object nativeObject = entry.NativeObject; } catch (Exception e) { errStr = e.Message().ToString(); } return errStr; } But this seems like a "weak" way of doing things. Or should I just make my method "void" and just not handle the exception so that it gets passed back to the calling function? void AuthenticateUser(string domain, string user, string pass) { // Instantiate Directory Entry object DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain, user, pass); // Force connection over network to authenticate object nativeObject = entry.NativeObject; } This seems the most sane to me (for some reason). Yet at the same time, the only real advantage of wrapping those 2 lines over just typing those 2 lines everywhere I need to authenticate is that I don't need to include the "LDAP://" string. The downside with this way of doing it is that the user has to put this method in a try-catch block. Thoughts? Is there another way of doing this that I'm not thinking of?

    Read the article

  • Given a main function and a cleanup function, how (canonically) do I return an exit status in Bash/Linux?

    - by Zac B
    Context: I have a bash script (a wrapper for other scripts, really), that does the following pseudocode: do a main function if the main function returns: $returncode = $? #most recent return code if the main function runs longer than a timeout: kill the main function $returncode = 140 #the semi-canonical "exceeded allowed wall clock time" status run a cleanup function if the cleanup function returns an error: #nonzero return code exit $? #exit the program with the status returned from the cleanup function else #cleanup was successful .... Question: What should happen after the last line? If the cleanup function was successful, but the main function was not, should my program return 0 (for the successful cleanup), or $returncode, which contains the (possibly nonzero and unsuccessful) return code of the main function? For a specific application, the answer would be easy: "it depends on what you need the script for." However, this is more of a general/canonical question (and if this is the wrong place for it, kill it with fire): in Bash (or Linux in general) programming, do you typically want to return the status that "means" something (i.e. $returncode) or do you ignore such subjectivities and simply return the code of the most recent function? This isn't Bash-specific: if I have a standalone executable of any kind, how, canonically should it behave in these cases? Obviously, this is somewhat debatable. Even if there is a system for these things, I'm sure that a lot of people ignore it. All the same, I'd like to know. Cheers!

    Read the article

  • Call a void* as a function without declaring a function pointer

    - by ToxIk
    I've searched but couldn't find any results (my terminology may be off) so forgive me if this has been asked before. I was wondering if there is an easy way to call a void* as a function in C without first declaring a function pointer and then assigning the function pointer the address; ie. assuming the function to be called is type void(void) void *ptr; ptr = <some address>; ((void*())ptr)(); /* call ptr as function here */ with the above code, I get error C2066: cast to function type is illegal in VC2008 If this is possible, how would the syntax differ for functions with return types and multiple parameters?

    Read the article

  • Void pointer values comparing C++

    - by user2962977
    My actual question is it really possible to compare values contained in two void pointers, when you actually know that these values are the same type? For example int. void compVoids(void *firstVal, void *secondVal){ if (firstVal < secondVal){ cout << "This will not make any sense as this will compare addresses, not values" << endl; } } Actually I need to compare two void pointer values, while outside the function it is known that the type is int. I do not want to use comparison of int inside the function. So this will not work for me as well: if (*(int*)firstVal > *(int*)secondVal) Any suggestions? Thank you very much for help!

    Read the article

  • Problem using void pointer as a function argument

    - by Nazgulled
    Hi, I can't understand this result... The code: void foo(void * key, size_t key_sz) { HashItem *item = malloc(sizeof(HashItem)); printf("[%d]\n", (int)key); ... item->key = malloc(key_sz); memcpy(item->key, key, key_sz); } void bar(int num) { foo(&num, sizeof(int)); } And I do this call: bar(900011009); But the printf() output is: [-1074593956] I really need key to be a void pointer, how can I fix this?

    Read the article

  • ~/.bashrc return can only 'return' from a function or sourced script

    - by Timothy
    I am trying to setup a OpenStack box to have a look at OpenStack Object Storage (Swift). Looking through the web I found this link; http://swift.openstack.org/development_saio.html#loopback-section I followed the instructions line by line but stuck on step 7 in the "Getting the code and setting up test environment" section. When I execute ~/.bashrc I get; line 6: return: can only 'return' from a function or sourced script. Below is the Line 6 extract from ~/.bashrc. My first reaction is to comment this line out, but I dont know what it does. Can anyone help? #If not running interactively, dont't do anything [ -z "$PS1" ] && return I'm running Ubuntu 12.04 as a VM on Hyper-v if knowing that is useful.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >