Pthread Cleanup Push Compile Error
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 or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up pthread_cleanup_push causes Syntax error up vote 0 down vote favorite I try to add a section to my code which is able to unlock the mutex in a case of cancellation. This may happen and would cause a deadlock. Therefore I tried to add pthread_cleanup_push(cleanup_unlock_mutex, &mutex_ftdi); but this line cause a syntax error from the line where I add it till the end of the code file. If I comment the code line the program will compile without any error. What I'm doing wrong? void cleanup_unlock_mutex(void *p){ pthread_mutex_unlock(p); } ....... }else{ for(unsigned count=0; count <= number_of_requests; count++){ pthread_cleanup_push(cleanup_unlock_mutex, &mutex_ftdi); pthread_mutex_lock(&mutex_ftdi); process_requests(count, numberofthread); pthread_mutex_unlock(&mutex_ftdi); } } // compiler error: error: expected ‘while’ before ‘}’ token .......... All other functions in the file get the warning: ISO C forbids nested functions [-pedantic]. c pthreads mutex share|improve this question asked Jul 1 '14 at 6:39 Irgendw Pointer 6571233 2 } missed. can you indent code first? strange!!!! else without if? where is while loop? post whole code. –Jayesh Jul 1 '14 at 6:40 1 but I do not want to post the if section of the code. if you not want then anyone not want give you answer. –Jayesh Jul 1 '14 at 6:44 1 @IrgendwPointer : I believe you that only the pthread line of code is causing problem that's why you don't want to show
Invalid Undecided petter wahlman Edit You need to log in to change this bug's status. Affecting: eglibc (Ubuntu) Filed here by: petter wahlman When: 2010-05-04 Assigned: 2010-08-23 Completed: 2010-08-23 Target Distribution Baltix BOSS Juju Charms Collection Elbuntu Guadalinex Guadalinex Edu Kiwi Linux nUbuntu PLD Linux Tilix tuXlab Ubuntu Ubuntu Linaro Evaluation Build Ubuntu RTM Package (Find…) Project (Find…) Status Importance Invalid Undecided Assigned to Me petter wahlman (petter-wahlman) Comment on this change (optional) Email me about changes to http://stackoverflow.com/questions/24503877/pthread-cleanup-push-causes-syntax-error this bug report Also affects project (?) Also affects distribution/package Nominate for series Bug Description Code to trigger the problem: ================================================================ #include
pthread https://sourceware.org/bugzilla/show_bug.cgi?id=4123 cleanup handler not called Summary: pthread cleanup handler not called Status: RESOLVED WORKSFORME Alias: None Product: glibc Classification: Unclassified Component: ports (show other bugs) Version: unspecified Importance: P2 normal Target Milestone: --- Assignee: Roland McGrath URL: Keywords: Depends on: Blocks: pthread cleanup Reported: 2007-03-02 15:18 UTC by Miroslav Kes Modified: 2010-09-03 15:16 UTC (History) CC List: 5 users (show) david.duitsman glibc-bugs kr null pth See Also: Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu, arm-xscale-be Build: i686-pc-linux-gnu Last reconfirmed: Attachments Tar file containing test program to produce the pthread cleanup push behavior with pthread_exit. (6.70 KB, application/gzip) 2007-09-08 17:37 UTC, K.R. Foley Details View All Add an attachment (proposed patch, testcase, etc.) Note You need to log in before you can comment on or make changes to this bug. Description Miroslav Kes 2007-03-02 15:18:26 UTC I use native or crosscompiler for arm-xscale-be gcc 4.1.1 and glibc 2.5. gcc configuration: Using built-in specs. Target: i686-pc-linux-gnu Configured with: /var/tmp/portage/gcc-4.1.1-r3/work/gcc-4.1.1/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.1 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --disable-multilib --disable-libmudflap --disable-libssp --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 4.1.1 (Gentoo 4.1.1-r3) or (the cross compiler) Using built-in specs. Target: armv5teb-softfloat-linux-gnueabi Configured with: ../gcc-4.1.1/configure --prefix=/tmp/clfs/cross-tools --host=i686-cross-linux-gnu --target=armv5teb-softfloat-linux-gnueabi --disable-multilib --with-sysroot=/tmp/clfs --disable-nls --enable-shared --enable-languages=c,c++ --enable-__cxa_atexit --enable-c99 --enable