Error No Return Statement In Function Returning Non-void - Werror=return-type
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers error non-void function should return a value or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x no return statement in function returning non-void c++ Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it return-statement with no value in function returning 'int' only takes a minute: Sign up C warning 'return' with no value, in function returning non-void up vote 2 down vote favorite I have this warning. warning : 'return' with no value, in function returning non-void. c warnings share|improve this
C++ Function Without Return Value
question asked Mar 11 '10 at 4:59 ambika 52951017 8 "Doctor, it hurts when I rub here!" "Well, stop doing it, then!" :-P Seriously, if a function has a return type, don't just return;, but return a value of the required type. –Chris Jester-Young Mar 11 '10 at 5:01 12 After looking at your questions, I think you should learn C from a good book, instead of by trial-and-error. It will be quicker and more rewarding. –Alok Singhal wreturn-type Mar 11 '10 at 5:02 1 @Alok - Or at least read the error messages more carefully instead of directing them all to Stack Overflow. –asveikau Mar 11 '10 at 5:06 1 some people have no knowledge of programming language. but they are here. @Alok @asvelkau - i think i am here to get some suggestion, not the ebook link. i think you guys are trainer. so put your head in class room, not here. –ambika Mar 11 '10 at 5:24 3 @ambika: I meant no offense, and I still think SO is not the right place to learn a language. However, you are welcome to, if that's they way you learn. –Alok Singhal Mar 11 '10 at 5:34 | show 1 more comment 3 Answers 3 active oldest votes up vote 9 down vote You have something like: int function(void) { return; } Add a return value, or change the return type to void. The error message is very clear: warning : 'return' with no value, in function returning non-void. A return with no value is similar to what I showed. The message also tells you that if the function returns 'void', it would not give the warning. But because the function is supposed to return a value but your 'return' statement didn't, you have a problem. This is often indicative of ancient code. In the days before the C89 standard, compilers did not ne
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About no return statement in function returning non-void [-wreturn-type] Us Learn more about Stack Overflow the company Business Learn more about hiring
No Return In Function Returning Non-void Eclipse
developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the
Dubious Tag Declaration
Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up why is this warning ( no http://stackoverflow.com/questions/2422636/c-warning-return-with-no-value-in-function-returning-non-void return , in function returning non-void)? up vote 0 down vote favorite void *rastertask() { struct sched_param sparm; memset(&sparm, 0, sizeof(sparm)); sparm.sched_priority = 10; /* 0 = lowest, 99 = highest */ sched_setscheduler( 0 /* pid, 0 ==> this process */, SCHED_RR /* policy */, &sparm); unsigned int n_loop; for(n_loop=0;;n_loop++) { struct timespec ts_start, ts_end; clock_gettime(CLOCK_REALTIME, &ts_start); TASK1(Task2ms_Raster); /* gets called every 2ms */ if( (n_loop http://stackoverflow.com/questions/23856895/why-is-this-warning-no-return-in-function-returning-non-void % 5) == 0) { TASK2(Task10ms_Raster); /* get called every 5 * 2ms = 10ms */ } if( (n_loop % 50) == 0) { TASK3(Task100ms_Raster); /* get called every 50 * 2ms = 100ms */ } if( (n_loop % 250) == 0 ) { /* reset loop counter when smallest common * multiple of timing grid has been reached */ n_loop = 0; } clock_gettime(CLOCK_REALTIME, &ts_end); useconds_t const tasks_execution_time = delta_t_us(&ts_start, &ts_end); if( tasks_execution_time >= MS_to_US(2) ) { /* report an error that tasks took longer than 2ms to execute */ } /* wait for 2ms - task_execution_time so that tasks get called in * a close 2ms timing grid */ else usleep( MS_to_US(2) - tasks_execution_time ); } } int main(int argc, char *argv[]) { pthread_t thread_id if (pthread_create(&thread_id, NULL, &rastertask, NULL)) { perror ("pthread_create"); exit (1); } return 0; } I am creating a thread in the main function. Created a scheduler in the function for calling the tasks for every 2milli seconds, 10 milli seconds and 100 milliseconds. I am getting a warning in the void *rastertask() as NO return, in function returning non-void. c linux timer scheduled-tasks scheduler share|improve this question asked Ma
statement in function returning non-void" compile error.Agile BoardCanned Response ExportJSONXMLWordPrintable Details Type: Bug Status: Closed Severity: Blocker Resolution: Fixed https://issues.asterisk.org/jira/browse/PRI-143 Affects Version/s: None Target Release Version/s: None Component/s: General Labels: None Environment: Ubuntu 12.04.1 LTS, gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Frequency of Occurrence: Constant Regression: http://www.cplusplus.com/forum/unices/154490/ No Description This appears to be an old condition that is caught by newer compilers. With gcc 4.6.3 it's possible to get the following in function error: $ make gcc -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC -O2 -MD -MT pridump.o -MF .pridump.o.d -MP -c -o pridump.o prid~ pridump.c: In function 'pri_bridge': pridump.c:117:1: error: no return statement in function returning non-void [-Werror=return-type] cc1: all warnings being treated as errors make: *** [pridump.o] Error 1 Changing in function returning the function return value to void fixes the issue since there were no places in the code that used the return value. Reported by: Birger "WIMPy" Harzenetter OptionsSort By NameSort By DateAscendingDescendingDownload AllAttachments 0001-Fix-no-return-statement-in-function-returning-non-vo.patch 07/Sep/12 11:39 PM 1 kB Shaun Ruffell Activity Ascending order - Click to sort in descending order All Comments Work Log History Activity CI Builds Transitions Gerrit Reviews Source Reviews Builds Hide Permalink Shaun Ruffell added a comment - 07/Sep/12 11:39 PM Attached 0001-Fix-no-return-statement-in-function-returning-non-vo.patch which is a trivial fix. Show Shaun Ruffell added a comment - 07/Sep/12 11:39 PM Attached 0001-Fix-no-return-statement-in-function-returning-non-vo.patch which is a trivial fix. Hide Permalink Shaun Ruffell added a comment - 07/Sep/12 11:47 PM - edited A note on how to use git to apply this patch quickly to the 1.4 branch of libpri. If you have git and subversion installed on your workstation, y
have tried several times to rid certain errors and then new ones will pop up. ANY help is greatly appreciated... errors after make g++47 -std=c++11 -Wall -Wextra -I. -I/home/courses/cop3330p/LIB/cpp -c main.cpp In file included from main.cpp:6:0: stats.cpp: In function ‘float Median(int*, size_t)’: stats.cpp:30:9: error: expected primary-expression before ‘int’ stats.cpp:30:28: error: expected primary-expression before ‘size’ stats.cpp:31:3: error: expected ‘;’ before ‘{’ token stats.cpp:24:9: warning: unused variable ‘Median’ [-Wunused-variable] stats.cpp:26:7: warning: unused variable ‘middle1’ [-Wunused-variable] main.cpp:46:1: error: expected ‘}’ at end of input main.cpp:46:1: warning: no return statement in function returning non-void [-Wreturn-type] In file included from main.cpp:6:0: stats.cpp: At global scope: stats.cpp:22:7: warning: unused parameter ‘array’ [-Wunused-parameter] make: *** [main.o] Error 1 godfrey@linprog3.cs.fsu.edu:~/cop3330/hw2> here is the stats.h #ifndef stats #define stats float Mean (const int* array,size_t size); //prototype for mean float Median (int* array,size_t size); //prototype for median void Sort (int* array,size_t size); //prototype for sort #endif _______ stats.cpp //retreives function prototypes #include "stats.h" #include