LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-03-2005, 10:02 PM   #1
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Rep: Reputation: 15
Splint parse error problem when used pthread


Hi all,
I want to use the Splint. But when I tryed I m getting parse error. Following is the code :
==================================================
------------------: Simple.c :--------------------
==================================================
#include<stdio.h>
#include<pthread.h>

void *thrdfun(void *arg)
{
printf("hi world..\n");
return NULL;
}
int main()
{
pthread_t thread;
char *ptr = malloc(5);;
strcpy(ptr,"rajesh");
printf("%s\n",ptr);
printf("Hi...\n");
pthread_create(&thread,NULL,thrdfun,NULL);
return 0;
}
==================================================



When used splint I got the following meassage:
==================================================
linux:~/SpLintDemo # splint -nolib -skipisoheaders -skipposixheaders Simple.c
Splint 3.1.1 --- 28 Apr 2003

/usr/include/bits/pthreadtypes.h:48:9:
Parse Error. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.
linux:~/SpLintDemo #
==================================================

And now I m stuck. I m not able to prceed....

Plz help me how to move.

With Regard
RajSun
 
Old 08-04-2005, 04:46 PM   #2
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
Is that the exact code?
  • Two semicolons after malloc
  • Only allocate 5 bytes for a 7 byte string (6 + '\0')
  • Worse, strcpy will gladly do it for you, so you're EXACT string will be 'rajes' with no null-terminator.

And please use [ code ] [ /code ] blocks, without the spaces in them. If people are going to read your code the least you could do is make it readable for them.

Code:
#include<stdio.h>
#include<pthread.h>

void *thrdfun(void *arg)
{
  printf("hi world..\n");
  return NULL;
}

int main()
{
  pthread_t thread;
  char *ptr = malloc(7);
  strcpy(ptr,"rajesh");
  
  printf("%s\n",ptr);
  printf("Hi...\n");

  pthread_create(&thread,NULL,thrdfun,NULL);
  return 0;
}
And really, why do you have that strcpy stuff in there? I'd remove the printf(...)'s, the char *ptr and strcpy and start from the beginning.

Code:
#include <stdio.h>
#include <pthread.h>

void *thrdfun(void *arg)
{
  printf("hi world..\n");
  return NULL;
}

int main()
{
  pthread_t thread;

  /* pthread_create returns 0 on success */
  if(pthread_create(&thread,NULL,thrdfun,NULL) != 0) {
    printf("simple.c: error creating pthread, exiting\n");
    return -1;
  }

  return 0;
}
I'd try that and see what happens, post errors after running it.

Last edited by lowpro2k3; 08-04-2005 at 05:00 PM.
 
Old 08-06-2005, 12:01 AM   #3
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Original Poster
Rep: Reputation: 15
Sorry for inconvenience......
Thanks for responce......
--------------------------------------------
But, my intension was to use splint.
Now I over come the problem. I m going to write down the steps to use the splint.
--------------------------------------------
1. splint checks all the depedencies for the given C file. Lets say in this way : Suppose the above mention code file name is "Simple.c". Therefore splint will check all the files on which Simple.c is dependent.
2. To konw the dependencies of a C file use following command.
"gcc -M Simple.c"
This will give u alist of files.
3. Now use splint with ur file name(Simple.c) as shown below.
"splint -I/usr/include -I/usr/include/sys -I/usr/include/bit (similarly all the directories on which ur C file depends) -skipposixheaders -skipisoheaders +D__gnuc_va_list=int +D__builtin_va_list=int Simple.c"
4. splint checks with strict C rules. Mean to say all the declarations and definitions of variable should be done first.
----------------------------------------------------------------
If any body face any problem while using the splint plz post the problem.......

Thanking u all.
With Regard
RajSun.
 
Old 09-11-2005, 11:24 PM   #4
deepak_khatri
LQ Newbie
 
Registered: Sep 2005
Posts: 1

Rep: Reputation: 0
Quote:
Originally posted by rajsun
Sorry for inconvenience......
Thanks for responce......
--------------------------------------------
But, my intension was to use splint.
Now I over come the problem. I m going to write down the steps to use the splint.
--------------------------------------------
1. splint checks all the depedencies for the given C file. Lets say in this way : Suppose the above mention code file name is "Simple.c". Therefore splint will check all the files on which Simple.c is dependent.
2. To konw the dependencies of a C file use following command.
"gcc -M Simple.c"
This will give u alist of files.
3. Now use splint with ur file name(Simple.c) as shown below.
"splint -I/usr/include -I/usr/include/sys -I/usr/include/bit (similarly all the directories on which ur C file depends) -skipposixheaders -skipisoheaders +D__gnuc_va_list=int +D__builtin_va_list=int Simple.c"
4. splint checks with strict C rules. Mean to say all the declarations and definitions of variable should be done first.
----------------------------------------------------------------
If any body face any problem while using the splint plz post the problem.......

Thanking u all.
With Regard
RajSun.

Quote:
Hi RajSun,
i Have the same problem with Splint 3.1.1 on HPUX 11i.
I have tried all the option but not able to solve the problem.

"MSedTs_PoChgQ.pc:165:10: Parse Error. (For help on parse errors, see splint
-help parseerrors.)"

when i was trying to solve the problem i got another error msg.

"splint Parse Error Non-function declaration"

Please help to solve the same.

Thanks in advance.

Deepak Khatri
 
Old 10-07-2010, 01:27 AM   #5
rathodiitc
LQ Newbie
 
Registered: Oct 2010
Posts: 1

Rep: Reputation: 0
Spec file not found: splint.lcl

Spec file not found: splint.lcl is the error messsage
dont know y this message apppears when i try to "make lint".
any ideas???????
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
in gcc compiler error: parse error before string constsnt cynthia_thomas Linux - Networking 1 10-20-2005 01:29 AM
c++ pthread error SIGSEGV almorris Programming 5 09-23-2005 05:14 PM
glibc make error: pthread.h DanielIvy Linux - Software 2 12-09-2004 06:40 AM
Error compiling with pthread Siriuss Programming 1 10-23-2004 08:21 AM
pthread problems and parse errors Stabby Red Hat 1 01-28-2004 10:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration