You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, April 16th 2012, 8:21am

Trouble with c-string functions.

I've included cstdio library in all .cpp files. In main.cpp i can use strlen but on the contrary in rest .cpp files i can't do this.

Source code

1
2
3
4
5
6
7
8
// some.cpp
#include <iostream>
#include <cstdio>
using namespace std;

int sdfsd() {
    strlen(); // compilier don't know about this function
}

Source code

1
2
3
4
5
6
7
// main.cpp
#include <cstdio>

int main(int argc, char *argv[])
{
    strlen(); // allright.
}

I've made new project yet - no results.

2

Monday, April 16th 2012, 8:41am

my opinion is "never" use such as:

Source code

1
using namespace std;

which make tings less clear

I write "never" because "always / never do something rules" are not good rules
it's just my opinion

3

Monday, April 16th 2012, 12:26pm

what do you mean 'compiler doesnt know'?

Show exact compiler error message, and exact COMPLETE code that gives that error.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

4

Monday, April 16th 2012, 5:28pm

I've attached screenshot of problem.
http://rghost.net/37615951 the whole project, it's the most helpful thing in my situation.

non-working code is more than 10 000 characters. It is in a flex.cpp file.
At 12 str - inclusion stdio.h;
at 795 str - using of strcpy and small above strlen.

I think the reason is in the linking or smth the same, but not exactly in the library.
KBAC has attached the following file:
  • Capture.JPG (24.98 kB - 5 times downloaded - latest: Apr 16th 2012, 10:14pm)

5

Monday, April 16th 2012, 6:25pm

your problem seems to be in .l / .y file (??? #line 75 "dscrptFlex_Perl.txt")
which is missing string.h

6

Monday, April 16th 2012, 6:32pm

Yes, that's it.
But i still don't understand why i was needed to string.h ?

7

Monday, April 16th 2012, 6:35pm

your problem seems to be in .l / .y file (??? #line 75 "dscrptFlex_Perl.txt")
which is missing string.h


<string.h> is not standard c++. correct is <cstring> :)
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

8

Monday, April 16th 2012, 6:46pm

not sure the generated parser is C++

even
sure the generated parser is not C++

so
what could be the problem including string.h

@KBAC
whithout the code of the parser, how could I tell why you need it
but sure generated parser uses, at least, strcpy

9

Monday, April 16th 2012, 7:00pm

I thought strcpy, strlen is cstdio functions.

I've just realize what's wrong ^^

This post has been edited 1 times, last edit by "KBAC" (Apr 16th 2012, 7:28pm)


Similar threads