Error length was not declared in this scope

I am beginner c++ programmer, It's my first program even (For those who are very keen to give negatives). I had written the same code in c but now trying to do in c++. Where I get the following err...

It’s a compile error and your code is responsible. You defined length inside your Huffman class. It’s a member of that class, not a global variable.

Imagine your class as a C Struct. You’d need to create a struct first in order to access the variable. Same thing applies to C++ classes.

Try Object1.length = 10; after you create the instance of your class.

EDIT

For your purposes, use C++ classes as you would use C structs. That will do the trick.

I would actually put the Node struct declaration outside of the Huffman class. I think it’s easier to understand. Also, using a typedef to a struct is not really that useful in C++ for these cases, the name of the struct is usable by just declaring the struct.

The pointers do not allocate memory for the struct themselves. Only after you allocate memory they will be usable, and even then they’re members of Object1, so you need that too.

#include <iostream>
#include <fstream>
#include <assert.h>
using namespace std;

struct Node
{
    int value;
    unsigned char sym;                 /* symbol */
};

 class Huffman
 {
    public:

    int data_size, length; //THis length variable is not accessible in main function below in main function.
     Huffman(char *filename);
   ~Huffman();

    Node *left,*right;    /* left and right subtrees */

 };

 Huffman::Huffman(char * file_name)
 {

 //I will do something here soon

 }
  Huffman::~Huffman()
 {

 }


 int main(int argc, char * * argv)
 {
      length=10; //Not accessible here.
     if (argc < 2)
    {
        cout<<"Ohh.. Sorry , you forgot to provide the Input File please" <<endl;
        return(0);
    }
     Huffman Object1(argv[1]);

     Object1.left  = new Node;
     Object1.right = new Node;

     //Do your stuff here...
     Object1.left->sym;

     return(0);


}

This should get you started, it is by no means a perfect implementation. It’s not even very C++ oriented, but I already went ahead of myself with the answer. This is a topic for a very different question, which you’re welcome to ask in SO, but try not to make questions inside questions.

Good luck!

  • Forum
  • Beginners
  • Length command and variable not declared

Length command and variable not declared in scope

I wrote a program to test my skills in using classes and now I’m stuck. I’m basically doing input validation right now. The third do while loop is giving me some problems. I want it to only accept 4 digits for the year. I am trying to use the length() command. This statement:

 
} while (yearString.length() != 4); 

It’s giving me: «dateProg.cpp:83:11: error: ‘yearString’ was not declared in this scope»
But I did declare it here:

 
std::string yearString = std::to_string(inputYear);

The only thing I can think of is that my data members for «setYear/getYear» are set to int right now, this may be causing a problem. I’m trying to use to_string in there as well as I can’t figurte out a way of using length without using a string.

Also, I would like to know if there is a more elegant way of doing my input validation. I am using a local variable (i) and incrementing it so the «invalid month!» «Invalid Day!» only comes up once. How else would I have the «input Day» prompt, for instance come up everytime, then the «Invalid Day» prompt come up only when invalid? I feel I’m using a workaround, but it works.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <iostream>
#include <cstdlib>


class Date {
	private: 
	int month;
	int day;
	int year;
	public:
	void setMonth(int);
	void setDay(int);
	void setYear(int);
	int getMonth();
	int getDay();
	int getYear();
};

void Date::setMonth(int m)
{
	month = m;
}
void Date::setDay(int d)
{
	day = d;
}
void Date::setYear(int y)
{
	year = y;
}
int Date::getMonth()
{
	return month;
}
int Date::getDay()
{
	return day;
}
int Date::getYear()
{
	return year;
}


int main() {
	
	Date dateInput;
	int inputMonth;
	int inputDay;
	int inputYear;
	do{
	int i = 0;
	std::cout << "Input Month " << std::endl;
	std::cin >> inputMonth;
	
	if (i > 0) {
	std::cout << "Invalid month!" << std::endl;
}
	i++;
	} while (inputMonth < 1 || inputMonth > 12);

	do{
	int i = 0;
	std::cout << "Input Day " << std::endl;
	std::cin >> inputDay;
	
	if (i > 0) {
	std::cout << "Invalid day!" << std::endl;
}
	i++;
	} while (inputDay < 1 || inputDay > 31);
		
	do{
	int i = 0;
	std::cout << "Input year" << std::endl;
	std::cin >> inputYear;
	std::string yearString = std::to_string(inputYear);
	//std::string countString = yearString.length();
	
	if (i > 0) {
	std::cout << "Invalid Year" << std::endl;
	}	
	i++;
	} while (yearString.length() != 4); // THIS IS MY PROBLEM

	//std::cout << "Input Year " << std::endl;
	//std::cin >> inputYear;
	
	dateInput.setMonth(inputMonth);
	dateInput.setDay(inputDay);
	dateInput.setYear(inputYear);
	
	std::cout << "The date is: " << dateInput.getMonth() << "/" << dateInput.getDay() << "/" << dateInput.getYear() << std::endl;
	
	
	return EXIT_SUCCESS;
	
}

Thanks in advance!

Variables declared inside the do-while loop are unfortunately out of scope in the loop condition.

You have to declare yearString outside the loop.

1
2
3
4
5
6
std::string yearString;
do {
	...
	yearString = std::to_string(inputYear);
	...
} while (yearString.length() != 4);

Last edited on

Ok, I did not know that, thanks! It is compiling now but the year validation is doing an infinite loop, even when I put in a 4 digit number. Could this be where me using int’s for my classes, setters and getters might be causing the problem?

Oh wait. Would I have to put all this validation outside the loop since it doesnt have scope access to it? I guess I could create a function maybe?

Inside the loop, make sure that you assign to the string that you created outside the loop.

 
std::string yearString = std::to_string(inputYear);

Last edited on

OMG! I never would have thought that putting std::string in front of it would make that big of a difference! Thank you! — If I could ask one more thing. Why? Why does that make such a big difference?

By C++ syntax,

(Type) (VariableName) = (Data); is declaring a new variable and initializing it with data

(VariableName) = (Data); is assigning data to a variable that ought to already exist.

When a declared parameter in an inner scope has the same name as the outer scope, it’s called «shadowing» a variable — a new variable is created, which has nothing to do with the former variable declared in an outer scope — and it’s best to avoid doing this.
https://en.wikipedia.org/wiki/Variable_shadowing

Last edited on

Ok Ganado, thanks for the response. So that wikipedia article basically says it is just confusing and bad practice.

— In my code how else could I do what I’m trying to do without shadowing?

«shadowing» was how you had it before. The yearString variable inside the loop shadowed the yearString variable that was declared outside the loop. After you removed std::string inside the loop there is only one variable named «yearString» and hence no shadowing.

Last edited on

Oh ok. Thanks!!

Do you really need a string?

1
2
3
4
int year = 0;
while ( std::cin >> year && !(999 < year && year < 10000) ) {
  std::cout << "Invalid Yearn";
}

Topic archived. No new replies allowed.

SergeyKagen

3 / 4 / 2

Регистрация: 02.04.2018

Сообщений: 315

1

19.04.2019, 22:16. Показов 131712. Ответов 14

Метки нет (Все метки)


Простой код, но Arduino IDE напрочь отказывается принимать переменные. Что за глюк или я что-то неправильно делаю?

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void setup() {
  
  Serial.begin(9600);
  int count = 0;
  pinMode(7, INPUT);
  pinMode(13, OUTPUT);
 
}
 
void loop() {
 
  if( digitalRead(7) == HIGH ){ 
    
    while(1){ 
      delayMicroseconds(2); 
      count++;  
      if( digitalRead(7) == LOW ){ Serial.println(count); count = 0; break; }
      }
    }  
}

ошибка при компиляции «‘count’ was not declared in this scope», что не так?

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



marat_miaki

495 / 389 / 186

Регистрация: 08.04.2013

Сообщений: 1,688

19.04.2019, 23:26

2

Лучший ответ Сообщение было отмечено SergeyKagen как решение

Решение

C++
1
2
3
4
5
6
7
8
  int count = 0; //глобальная переменная
 
  void setup() {
   Serial.begin(9600);
  pinMode(7, INPUT);
  pinMode(13, OUTPUT);
 
}



1



Lavad

0 / 0 / 0

Регистрация: 03.10.2015

Сообщений: 25

14.09.2019, 22:33

3

Доброго времени суток!
У меня то же сообщение, но на функцию :-(
Создал функцию (за пределами setup и loop), которая только принимает вызов, ничего не возвращает:

C++
1
2
3
4
5
void myDispay(byte x, byte y, char str) {
  lcd.setCursor(x, y);
  lcd.print(temp, 1);   // выводим данные, с точностью до 1 знака после запятой
  lcd.print(str);   // выводим писанину
  }

В loop() делаю вызов:

C++
1
myDisplay(0,0,"C");

При компиляции выделяется этот вызов, с сообщением:

‘myDisplay’ was not declared in this scope

Замучился искать инфу о декларации/обьявлении функции. Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции
Что делаю не так? В чем моя ошибка? Помогите, пожалуйста.

P.S. Код, что использовал в качестве функции, работоспособен. Раньше находился в loop(). Скетч постепенно разрастается, много однотипных обращений к дисплею…



0



Эксперт С++

8385 / 6147 / 615

Регистрация: 10.12.2010

Сообщений: 28,683

Записей в блоге: 30

14.09.2019, 23:57

4

Цитата
Сообщение от Lavad
Посмотреть сообщение

Создал функцию (за пределами setup и loop),

Перевидите на нормальный язык.
Какие еще пределы?

В другом файле что ли?

Добавлено через 1 минуту

Цитата
Сообщение от Lavad
Посмотреть сообщение

Замучился искать инфу о декларации/обьявлении функции. Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции
Что делаю не так? В чем моя ошибка? Помогите, пожалуйста

Читать учебники по С++ не пробовали?

https://metanit.com/cpp/tutorial/3.1.php
http://cppstudio.com/post/5291/

Специфика Arduino лишь отличается тем что пред объявления не всегда нужны.

Добавлено через 7 минут
Кроме того иногда потеряй скобок {} приводят к таким ошибкам.



0



ValeryS

Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

15.09.2019, 00:09

5

Цитата
Сообщение от Lavad
Посмотреть сообщение

Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции

это где ж такое написано?
функцию нужно объявить перед первым вызовом, сиречь сверху
можно и просто декларировать сверху

C++
1
void myDispay(byte x, byte y, char str);

а объявить уже в удобном месте



0



0 / 0 / 0

Регистрация: 03.10.2015

Сообщений: 25

15.09.2019, 00:48

6

Неделю назад ВПЕРВЫЕ включил Arduino Uno.
Задолго до этого писал программы под Windows (БейсикВизуал) и AVR (Basic, немного Assembler). Т.е. имеется некоторое представление об объявлении переменных, функций,… От Си всегда держался как можно дальше. Это первая и последняя причина «нечитания» книг по Си. За неделю экспериментов на Arduino мнение об этом пока не изменилось — легче вернуться к Ассму, чем копаться в Си.

Написал на том же языке, что и читал на всяких форумах и справочниках по Arduino :-). За пределами этих функций — значит не внутри них.

Обе приведенных Вами ссылок просмотрел, проверил в скетче… В итоге вылезла другая ошибка:
function ‘void myDisplay(byte, byte, char)’ is initialized like a variable

void myDisplay(byte x, byte y, char str) тоже пробовал. Та же ошибка.

Что не так на этот раз? :-(



0



Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

15.09.2019, 01:26

7

Цитата
Сообщение от Lavad
Посмотреть сообщение

В итоге вылезла другая ошибка:
function ‘void myDisplay(byte, byte, char)’ is initialized like a variable

точку с запятой в конце поставил?



1



Lavad

0 / 0 / 0

Регистрация: 03.10.2015

Сообщений: 25

15.09.2019, 08:46

8

Вот скетч. Проще некуда.

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <PCD8544.h>
 
float temp = 0;
static PCD8544 lcd;   // даем имя подключенному дисплею (lcd)
static const byte Lm35Pin = 14;   // аналоговый пин (A0) Arduino, к которому подключен LM35
 
//void myDisplay() = 0;
//void myDisplay(byte, byte, char, float) = 0;
//void myDisplay(byte x, byte y, char str, float temp) = 0;
 
void myDispay(byte x, byte y, char str, float temp) {
  lcd.setCursor(x, y);   // начиная с (x,y)...
  lcd.print(temp, 1);   // выводим temp
  lcd.print(str);   // выводим писанину
}
 
void setup() {
  lcd.begin(84, 48);   // инициализируем дисплей
  analogReference(INTERNAL);   // подключаем внутренний ИОН на 1.1V
}
 
void loop() {
  float temp = analogRead(Lm35Pin) / 9.31;  // подсчитываем температуру (в Цельсиях)...
  myDisplay(0, 0, "C", temp);   // отправляем данные на экран
  delay(500);   // ждем 500 мсек
}

Любое из трех так называемых «объявлений» (строки 7…9) выдает одну и ту же ошибку — я пытаюсь объявить функцию как переменную.

Добавлено через 9 минут
Попробовал так:

C++
1
void myDisplay(byte x, byte y, char str, float temp);

Компилятор задумался (я успел обрадоваться), но, зараза :-), он снова поставил свой автограф :-)

undefined reference to `myDisplay(unsigned char, unsigned char, char, float)

На этот раз он пожаловался на строку вызова функции.

Добавлено через 34 минуты
Когда что-то новое затягивает, забываешь о нормальном отдыхе, теряешь концентрацию…
Нашел ошибку. Чистейшая грамматика

C++
1
void myDispay(byte x,...

Dispay вместо Display

Добавлено через 8 минут
ValeryS, благодарю за попытку помощи!



0



ValeryS

Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

15.09.2019, 10:36

9

Цитата
Сообщение от Lavad
Посмотреть сообщение

void myDisplay(byte, byte, char, float) = 0;

вот так не надо делать(приравнивать функцию к нулю)
так в классическом С++ объявляют чисто виртуальные функции, и класс в котором объявлена чисто виртуальная функция становится абстрактным. Означает что у функции нет реализации и в дочернем классе нужно обязательно реализовать функцию. А из абстрактного класса нельзя создать объект

Добавлено через 5 минут

Цитата
Сообщение от Lavad
Посмотреть сообщение

void myDispay(byte x, byte y, char str, float temp)

Цитата
Сообщение от Lavad
Посмотреть сообщение

myDisplay(0, 0, «C», temp);

просишь чтобы функция принимала символ char str, а передаешь строку "C"
или передавай символ

C++
1
myDisplay(0, 0, 'C', temp);

или проси передавать строку, например так

C++
1
void myDispay(byte x, byte y, char * str, float temp);



1



Avazart

Эксперт С++

8385 / 6147 / 615

Регистрация: 10.12.2010

Сообщений: 28,683

Записей в блоге: 30

15.09.2019, 12:02

10

Кроме того наверное лучше так:

C++
1
2
3
4
5
6
7
8
void myDispay(PCD8544& lcd,byte x, byte y, char str, float temp) 
{
  lcd.setCursor(x, y);   // начиная с (x,y)...
  lcd.print(temp, 1);   // выводим temp
  lcd.print(str);   // выводим писанину
}
 
myDisplay(lcd,0, 0, 'C', temp);

Тогда можно будет вынести ф-цию в отдельный файл/модуль.



1



locm

15.09.2019, 21:07

Не по теме:

Цитата
Сообщение от Lavad
Посмотреть сообщение

Arduino Uno.

Цитата
Сообщение от Lavad
Посмотреть сообщение

AVR (Basic, немного Assembler).

Arduino Uno это AVR, для которого можете писать на бейсике или ассемблере.



0



Avazart

15.09.2019, 21:21

Не по теме:

Цитата
Сообщение от locm
Посмотреть сообщение

Arduino Uno это AVR, для которого можете писать на бейсике или ассемблере.

Но лучше не надо …



0



Lavad

0 / 0 / 0

Регистрация: 03.10.2015

Сообщений: 25

16.09.2019, 12:12

13

Цитата
Сообщение от ValeryS
Посмотреть сообщение

это где ж такое написано?
функцию нужно объявить перед первым вызовом, сиречь сверху
можно и просто декларировать сверху
а объявить уже в удобном месте

Оказалось, что я верно понял чтиво по справочникам: если ты вызываешь функцию, это и есть обьявление функции. А сама функция может располагаться по скетчу в ЛЮБОМ месте (но за пределами setup, loop и любых других функций). И больше никаких специфических строк.

Цитата
Сообщение от ValeryS
Посмотреть сообщение

вот так не надо делать(приравнивать функцию к нулю)…

Методом проб и ошибок уже понял :-).

Цитата
Сообщение от ValeryS
Посмотреть сообщение

или передавай символ… 'C'

Если передаю в одинарных кавычках

более одного

символа, а функция ждет как char str, то выводятся на экран только самый правый из отправленных символов. Отправил «абв», а выводится «в».
Выкрутился, прописав в функции char str[], а символы отправляю через двойные кавычки.

Цитата
Сообщение от ValeryS
Посмотреть сообщение

или проси передавать строку, например так… char * str

Буквально вчера попалось это в справочнике, но как-то не дошло, что тоже мой вариант :-).

Цитата
Сообщение от Avazart
Посмотреть сообщение

Кроме того наверное лучше так:

C++
1
void myDispay(PCD8544& lcd,byte x, byte y, char str, float temp) {...}

Тогда можно будет вынести ф-цию в отдельный файл/модуль.

Благодарю за совет! Как-нибудь проверю…



0



Эксперт С++

8385 / 6147 / 615

Регистрация: 10.12.2010

Сообщений: 28,683

Записей в блоге: 30

16.09.2019, 12:54

14

Цитата
Сообщение от Lavad
Посмотреть сообщение

Оказалось, что я верно понял чтиво по справочникам: если ты вызываешь функцию, это и есть обьявление функции

Нафиг выкиньте эти справочники.
Почитайте мои ссылки.



0



0 / 0 / 0

Регистрация: 03.10.2015

Сообщений: 25

16.09.2019, 13:00

15

Ссылки Ваши добавлены в закладки. Время от времени заглядываю.
Но теория для меня — всего лишь набор понятий. Я же высказался после практической проверки. А как я понял, так оно и работает :-)



0



I am trying to compile several third-party software from source code (i.e. zchaff, argosat) and get errors such as:

Error: ‘strlen’ was not declared in this scope
Error: ‘strcmp’ was not declared in this scope

Here’s the full error message text (also on Ubuntu Pastebin):

erelsgl@erel-biu:~/Dropbox/theorem-prover/argosat-1.0$ make
make  all-recursive
make[1]: Entering directory `/home/erelsgl/Dropbox/theorem-prover/argosat-1.0'
Making all in src
make[2]: Entering directory `/home/erelsgl/Dropbox/theorem-prover/argosat-1.0/src'
Making all in strategies
make[3]: Entering directory `/home/erelsgl/Dropbox/theorem-prover/argosat-1.0/src/strategies'
/bin/bash ../../libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../.. -I../../src -I../../src/auxiliary -I../../src/basic-types   -ffloat-store -Wall -Woverloaded-virtual -ansi -pedantic -Wno-strict-aliasing -DNDEBUG -O3 -MT libstrategies_la-RestartStrategy.lo -MD -MP -MF .deps/libstrategies_la-RestartStrategy.Tpo -c -o libstrategies_la-RestartStrategy.lo `test -f 'RestartStrategy.cpp' || echo './'`RestartStrategy.cpp
 g++ -DHAVE_CONFIG_H -I. -I../.. -I../../src -I../../src/auxiliary -I../../src/basic-types -ffloat-store -Wall -Woverloaded-virtual -ansi -pedantic -Wno-strict-aliasing -DNDEBUG -O3 -MT libstrategies_la-RestartStrategy.lo -MD -MP -MF .deps/libstrategies_la-RestartStrategy.Tpo -c RestartStrategy.cpp -o libstrategies_la-RestartStrategy.o
In file included from ../../src/SolverListener.hpp:22:0,
                 from RestartStrategyConflictCounting.hpp:24,
                 from RestartStrategyMinisat.hpp:22,
                 from RestartStrategy.cpp:22:
../../src/basic-types/Literal.hpp: In static member function ‘static void ArgoSat::Literals::shuffleVector(std::vector<unsigned int>&)’:
../../src/basic-types/Literal.hpp:83:23: error: ‘rand’ was not declared in this scope
RestartStrategy.cpp: In static member function ‘static ArgoSat::RestartStrategy* ArgoSat::RestartStrategy::createFromCmdLine(ArgoSat::Solver&, int, char**, int)’:
RestartStrategy.cpp:33:40: error: ‘strcmp’ was not declared in this scope
RestartStrategy.cpp:35:37: error: ‘strcmp’ was not declared in this scope
RestartStrategy.cpp:37:37: error: ‘strcmp’ was not declared in this scope
RestartStrategy.cpp:39:34: error: ‘strcmp’ was not declared in this scope
RestartStrategy.cpp:41:36: error: ‘strcmp’ was not declared in this scope
RestartStrategy.cpp:43:41: error: ‘strcmp’ was not declared in this scope
make[3]: *** [libstrategies_la-RestartStrategy.lo] Error 1
make[3]: Leaving directory `/home/erelsgl/Dropbox/theorem-prover/argosat-1.0/src/strategies'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/erelsgl/Dropbox/theorem-prover/argosat-1.0/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/erelsgl/Dropbox/theorem-prover/argosat-1.0'
make: *** [all] Error 2
erelsgl@erel-biu:~/Dropbox/theorem-prover/argosat-1.0$

I found in other questions, such as https://stackoverflow.com/questions/4564850/strlen-was-not-declared-in-this-scope-c, that these errors can be solved by inserting «include» statements into the source code.

But, I downloaded the source code from other sites and I am pretty sure it works for them as is. So, why doesn’t it work for me?

(I have Ubuntu 12.04.4, g++ 4.6.3)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Comments

@thisiskeithb

Description

Using the latest commit (b119c14), I am getting the following error messages when trying to compile for an SKR 1.3:

Compiling .pio/build/LPC1768/src/src/module/planner_bezier.cpp.o
Marlin/src/lcd/ultralcd.cpp:47:48: error: 'LONG_FILENAME_LENGTH' was not declared in this scope
     constexpr uint8_t MAX_MESSAGE_LENGTH = max(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH));
                                                ^~~~~~~~~~~~~~~~~~~~
Marlin/src/lcd/ultralcd.cpp:47:48: note: suggested alternative: 'TONE_QUEUE_LENGTH'
     constexpr uint8_t MAX_MESSAGE_LENGTH = max(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH));
                                                ^~~~~~~~~~~~~~~~~~~~
                                                TONE_QUEUE_LENGTH
Compiling .pio/build/LPC1768/src/src/module/printcounter.cpp.o

Edit: After further testing, 6a865a6 is the source of this bug.

Steps to Reproduce

  1. Use my config / this build and try to compile
  2. Observe error message

Expected behavior: Successful compile.

Actual behavior: Failed compile.

@thisiskeithb
thisiskeithb

changed the title
[BUG] Planner_bezier.cpp LONG_FILENAME_LENGTH was not declared in this scope

[BUG] ultralcd.cpp LONG_FILENAME_LENGTH was not declared in this scope

Oct 10, 2019

@tvixen

Thiese two should fix the long filename support
#define LONG_FILENAME_HOST_SUPPORT
#define SCROLL_LONG_FILENAMES

But the question is why you have different display’s setup on your ender 3? did you replace your CR10 origin display ?

@thisiskeithb

Thiese two should fix the long filename support
#define LONG_FILENAME_HOST_SUPPORT
#define SCROLL_LONG_FILENAMES

This does not work.

But the question is why you have different display’s setup on your ender 3? did you replace your CR10 origin display ?

I have CR10_STOCKDISPLAY in my config, which is the stock Ender-3 LCD.

@tvixen

Oki…sorry. I just saw severals LCD displays in your config file. But now when I check again it’s normal CR10 stock display :) ??

So the question is: You just downloaded the new version of 2.0x and compiled it (without changing anything) and it gives you these errors….right?
Did you previously compile ok, for this board ? or is it a new setup to test ?

@tvixen

I see Scott is working on this one. So I’m sure the Issue will be solved shortly 👍

@thisiskeithb

Oki…sorry. I just saw severals LCD displays in your config file. But now when I check again it’s normal CR10 stock display :) ??

I’m not sure where you’re looking other than what I’ve linked, but I only have one LCD active in my config.

So the question is: You just downloaded the new version of 2.0x and compiled it (without changing anything) and it gives you these errors….right? Did you previously compile ok, for this board ? or is it a new setup to test ?

This was a rebased config that I’ve been using since the beginning of the year.

@thisiskeithb

I’m guessing this bug has something to do with changes made in 6a865a6.

Edit: Confirmed that rolling back to the commit before (dc14d4a), I am able to compile.

@thinkyhead: When are we going to have an actual feature freeze 🙂

@CRCinAU

Just wondering if there is any progress on this? Seems to still be broken.

@thisiskeithb

Just wondering if there is any progress on this? Seems to still be broken.

Nope. Still broken in my config after rebasing to the latest commit.

@Morallying

Hrm, for me it only occurred when I disabled SDSUPPORT. Since I am running on an Ender 3, I just added #define LONG_FILENAME_LENGTH 0 to Conditionals_LCD.h under #elif ENABLED(CR10_STOCKDISPLAY) First checking to see if SDSUPPORT was disabled before doing so.
Compiles fine now, though I have yet to flash it….

EDIT: Just flashed with the changes above, everything seems fine, am calibrating linear advance now :)

@CRCinAU

Yeah, I have SDSUPPORT disabled too as the Ender 3 doesn’t really have much space for better features!

@thisiskeithb

Hrm, for me it only occurred when I disabled SDSUPPORT.

Enabling SDSUPPORT allowed me to compile! I have a print going right now, but I’ll test it out later tonight.

SDSUPPORT is disabled in the default config, so I wonder why the test builds aren’t catching this bug.

@thisiskeithb
thisiskeithb

changed the title
[BUG] ultralcd.cpp LONG_FILENAME_LENGTH was not declared in this scope

[BUG] Can’t compile with SDSUPPORT disabled — LONG_FILENAME_LENGTH was not declared in this scope

Oct 16, 2019

@chrisqwertz

Just had the same problem with the latest bugfix2.0, eg. same error during compilation with disabled SDSUPPORT

Conf & Conf_adv
Marlin.zip

@thisiskeithb

@Rotule666

Thanks for the props, I didn’t do much but I will try to contribute more ;)

@github-actions

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Topic: wxWidgets problem: ‘strlen’ not declared in this scope  (Read 39566 times)

Hi!

Since I’ve been running into problems compiling projects using wxWidgets I just took a simple helloWorld.cpp and

#include

d

wx/wx.h

#include <iostream>
#include "wx/wx.h"

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

These are the first lines of the build messages:

C:ProgrammewxWidgets-2.8.9includewxwxchar.h||In function `size_t wxStrlen(const wxChar*)’:
C:ProgrammewxWidgets-2.8.9includewxwxchar.h|845|error: `strlen’ was not declared in this scope
C:ProgrammewxWidgets-2.8.9includewxwxchar.h||In function `char* wxTmemchr(const void*, int, size_t)’:
C:ProgrammewxWidgets-2.8.9includewxwxchar.h|1371|error: `memchr’ was not declared in this scope
C:ProgrammewxWidgets-2.8.9includewxwxchar.h||In function `int wxTmemcmp(const void*, const void*, size_t)’:

Maybe I screwed up sth. because the first time I tried everything worked just fine.

The global wx variable is set to the appropriate path. I copied the setup.h to the <WXWIN>/include/wx (although I am not sure if this is the proper way to get it into the include path…)

Any ideas on this?

Setup:
C::B nightly Aug-23-2008 (5193),
wxWidgets 2.8.9,
MinGW3.4.5


Logged

C::B NB 2008-09-21 (5203)
MinGW 3.4.5
WinXP


Copying «setup.h» is not the right way, it contains setup definitions, that depend on the options you have used while compiling wxWidgets.
I sometimes read this «tip» on the forum and I think it is potential dangerous, even if it seems to work in the most cases.

If your project is setup correctly you don’t need to copy anything.

Read http://wiki.codeblocks.org/index.php?title=WxWindowsQuickRef how to build wxWidgets and prepare C::B for the use of it, or look at the options of a wizard-created project.


Logged


Hm, ok, I removed setup.h from …/wx/include now and included the path I initially copied it from in the (global) compiler options.

But this wasn’t what caused the errors, they remain the same, even if I comment out the

#include

of

wx/wx.h

now, even if I remove anything related to wxWidgets from the project and clean it. I’ll have a look at a wizard generated project now, like proposed…

Well, firstly setup.h is not found, I add the absolute path to the project’s settings (it was there already but through the relative definition of the global wx variable which for some reason didn’t work), then there arise new errors, e.g.

C:ProgrammewxWidgets-2.8.9includewxbuffer.h|127|error: `strdup’ was not declared in this scope

which reminds me a lot of the errors I got previously.

Damn.  :?

Well, so I will recompile wxWidgets now, let’s see…


Logged

C::B NB 2008-09-21 (5203)
MinGW 3.4.5
WinXP


didn’t work…  :(
but I have to admit that I did not really recompile it, i.e. I didn’t clean before I did (I’ll do this tomorrow)… actually I don’t think that a wxWidgets rebuild will solve the problem since the errors all refer to the header files which should be the same with or without a compiled library, shouldn’t they?
I’ll keep trying and will inform you when I find out what is the problem or when I find a solution (but I’d prefer to know what I am doing wrong).


Logged

C::B NB 2008-09-21 (5203)
MinGW 3.4.5
WinXP


Looks more like a problem with your MinGW setup for me, because strlen is a standard c++-function.
Make sure your search-paths are set correctly.

As far as I know, «strlen» and «strdup» are declared in «string.h», which is in MinGW’s include folder (e.g. «c:MinGWinclude»).


Logged


You were right. Together with the wxWidgets search paths I also deleted the mingw/include from the search directories.

It had to be that simple…  :)

Thank you.
:D :D :D


Logged

C::B NB 2008-09-21 (5203)
MinGW 3.4.5
WinXP


harkin

Hi all. Been having a similar problem to IIIf (or is it lllf?). Anyway…

I kept getting the error about strup

C:ProgrammewxWidgets-2.8.9includewxbuffer.h|127|error: `strdup’ was not declared in this scope

I’d included the DirectX sdk include path in my search path, and after pushing it to the bottom of the list and pulling the Mingw include path to the top my basic wx.cpp compiles fine.

P.S. I used this post to compile wxWidgets properly

http://wiki.codeblocks.org/index.php?title=Compiling_wxWidgets_2.8.6_to_develop_Code::Blocks_(MSW)

Thanks guys and gals


Logged


Hi I have similiar problem and it doesn’t matter if I will compile wxWidgets from the source code or use wxPack I’m always ending up with the same result wchich is:

C:wxWidgets-2.8.11includewxchkconf.h|1824|warning: «wxUSE_WX_RESOURCES» is not defined|
C:wxWidgets-2.8.11includewxdefs.h|978|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxdefs.h|979|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxbuffer.h||In constructor ‘wxCharBuffer::wxCharBuffer(const char*)’:|
C:wxWidgets-2.8.11includewxbuffer.h|128|error: ‘strdup’ was not declared in this scope|

C:wxWidgets-2.8.11includewxbuffer.h||In member function ‘wxCharBuffer& wxCharBuffer::operator=(const char*)’:|
C:wxWidgets-2.8.11includewxbuffer.h|128|error: ‘strdup’ was not declared in this scope|
C:wxWidgets-2.8.11includewxbuffer.h||In constructor ‘wxWCharBuffer::wxWCharBuffer(const wchar_t*)’:|
C:wxWidgets-2.8.11includewxbuffer.h|135|error: ‘_wcsdup’ was not declared in this scope|
C:wxWidgets-2.8.11includewxbuffer.h||In member function ‘wxWCharBuffer& wxWCharBuffer::operator=(const wchar_t*)’:|
C:wxWidgets-2.8.11includewxbuffer.h|135|error: ‘_wcsdup’ was not declared in this scope|
C:wxWidgets-2.8.11includewxstring.h||In function ‘int Stricmp(const char*, const char*)’:|
C:wxWidgets-2.8.11includewxstring.h|141|error: ‘strcasecmp’ was not declared in this scope|
C:wxWidgets-2.8.11includewxstring.h|1073|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxstring.h|1079|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxstring.h|1191|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxstring.h|1193|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlist.h||In constructor ‘wxListKey::wxListKey(const wxChar*)’:|
C:wxWidgets-2.8.11includewxlist.h|406|error: ‘strdup’ was not declared in this scope|

C:wxWidgets-2.8.11includewxlist.h||In constructor ‘wxListKey::wxListKey(const wxString&)’:|
C:wxWidgets-2.8.11includewxlist.h|408|error: ‘strdup’ was not declared in this scope|
C:wxWidgets-2.8.11includewxhashmap.h|536|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|536|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|537|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|537|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h||In member function ‘long long unsigned int wxIntegerHash::operator()(long long int) const’:|
C:wxWidgets-2.8.11includewxhashmap.h|536|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|556|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|556|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|557|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|557|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxmath.h||In function ‘bool wxIsSameDouble(double, double)’:|
C:wxWidgets-2.8.11includewxmath.h|102|warning: comparing floating point with == or != is unsafe|
C:wxWidgets-2.8.11includewxlonglong.h|114|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|133|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|135|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|174|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|199|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|201|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|223|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|225|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|340|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h||In constructor ‘wxLongLongNative::wxLongLongNative(wxInt32, wxUint32)’:|
C:wxWidgets-2.8.11includewxlonglong.h|119|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|120|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h||In member function ‘wxLongLongNative& wxLongLongNative::Assign(double)’:|
C:wxWidgets-2.8.11includewxlonglong.h|157|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|351|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|371|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|373|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|402|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|427|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|429|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|446|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|448|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|563|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h||In constructor ‘wxULongLongNative::wxULongLongNative(wxUint32, wxUint32)’:|
C:wxWidgets-2.8.11includewxlonglong.h|356|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|357|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|1070|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|1071|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|1073|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|1074|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxfilefn.h|198|warning: ISO C++ 1998 does not support ‘long long’|
||=== Build finished: 7 errors, 45 warnings ===|

I’m trying to solve this problem for about 3 days now … and I’m loosing my mind here … so anyone please help me  :?


Logged


Are you sure that «X:MinGWinclude» directory is in your «Search directories»?


Logged


I’m using Win 7 64bit and it looks like my wxWidgets compilation fails … in fact I have tried to compile the source many times using diffrent versions of wxWidgets and also to redirect the output of compilation into a file rather than console but if fails more or less with the same error message


gcc_mswudllmonodll_debugrpt.o: file not recognized: Memory exhausted
collect2: ld returned 1 exit status
mingw32-make: *** [….libgcc_dllwxmsw291u_gcc_custom.dll] Error 1

I did attached full warrning/error log for comparision.

my global variable base is C:wx were C:wx is main folder with my source code …

project build options->search directories:
C:MinGWinclude
$(#wx)include
$(#wx)libgcc_dllmswu

Target is set for Release

project build options->release->search directories:
$(#wx)libgcc_dllmswu

I’m trying to compile the source code using following commands

cd C:wxbuildmsw

mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release clean

mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release > install_log.txt

System Path is set to C:MinGWbin    :?


Logged


I’m using Win 7 64bit and it looks like my wxWidgets compilation fails …

You are using the 32 bit mingw under a 64 bit OS, maybe there is a mix-up with some of the libraries? Your message log indicates a linker error…

Ken


Logged


is there 64bit version of mingw ?


Logged


I’m using Win 7 64 bit too. And using 32 bit compiler. So the reason not it. But i’ve build wxWidgets as static library.


Logged


I’m using Win 7 64 bit too. And using 32 bit compiler. So the reason not it. But i’ve build wxWidgets as static library.

StelRat did you had similiar problems with compilation before you tried to compile as static library ?


Logged


No. I had never used DLL. I hate them. =) For threading i need one, but that is other story.


Logged


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <sys/socket.h>
#include <sys/unistd.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <netinet/in.h>
#include <signal.h>
#include <iostream>
#include <thread>

using namespace std;

#define BUFFSIZE 2048
#define DEFAULT_PORT 4001    //
#define MAXLINK 2048

void connecter()
{
    printf("Listening...n");
    while (true)
    {
        signal(SIGINT, stopServerRunning);    // 
        // 
        connfd = accept(sockfd, NULL, NULL);
        if (-1 == connfd)
        {
            printf("Accept error(%d): %sn", errno, strerror(errno));
            return -1;
        }
    }
}

void listener()
{
    while(true)
    {
        bzero(buff, BUFFSIZE);
        //
        recv(connfd, buff, BUFFSIZE - 1, 0);
        // 
        printf("клиент: %sn", buff);
        //
        send(connfd, buff, strlen(buff), 0);
    }
}

void sender()
{
    while(true)
    {
        printf("Please input: ");
        scanf("%s", buff);
        send(connfd, buff, strlen(buff), 0);
        bzero(buff, sizeof(buff));
        recv(connfd, buff, BUFFSIZE - 1, 0);
        printf("recv: %sn", buff);
    }
}

int sockfd, connfd; 
void stopServerRunning(int p)
{
    close(sockfd);
    printf("Close Servern");
    exit(0);
}
int main()
{
    struct sockaddr_in servaddr;
    char buff[BUFFSIZE];
    //
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (-1 == sockfd)
    {
        printf("Create socket error(%d): %sn", errno, strerror(errno));
        return -1;
    }
    // 
    // 
    bzero(&servaddr, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
    servaddr.sin_port = htons(DEFAULT_PORT);
    if (-1 == bind(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)))
    {
        printf("Bind error(%d): %sn", errno, strerror(errno));
        return -1;
    }
    // 
    //
    if (-1 == listen(sockfd, MAXLINK))
    {
        printf("Listen error(%d): %sn", errno, strerror(errno));
        return -1;
    }
    
    while(true)
    {
        thread my_thread(connecter);
        if(connfd == true)
            break;
    }

    thread my_thread(connecter);
    thread my_thread(listener);
    thread my_thread(sender);

    return 0;
}

}

это исходный код программы, хотел написать что-то вроде чата на сокетах. Я попытался скомпилировать код, но он мне выдал несколько ошибок «was not declared in this scope». Вот вывод компилятора:

server.cpp: In function ‘void connecter()’:
server.cpp:24:24: error: ‘stopServerRunning’ was not declared in this scope
   24 |         signal(SIGINT, stopServerRunning);    // Это предложение используется для выключения сервера при вводе Ctrl + C
      | 

server.cpp:26:9: error: ‘connfd’ was not declared in this scope
   26 |         connfd = accept(sockfd, NULL, NULL);
      |         ^~~~~~

server.cpp:26:25: error: ‘sockfd’ was not declared in this scope; did you mean ‘socket’?
   26 |         connfd = accept(sockfd, NULL, NULL);
      |                         ^~~~~~
      |                         socket

server.cpp: In function ‘void listener()’:
server.cpp:39:15: error: ‘buff’ was not declared in this scope
   39 |         bzero(buff, BUFFSIZE);
      |               ^~~~

server.cpp:41:14: error: ‘connfd’ was not declared in this scope
   41 |         recv(connfd, buff, BUFFSIZE - 1, 0);
      |              ^~~~~~

server.cpp: In function ‘void sender()’:
server.cpp:54:21: error: ‘buff’ was not declared in this scope
   54 |         scanf("%s", buff);
      |                     ^~~~

server.cpp:55:14: error: ‘connfd’ was not declared in this scope
   55 |         send(connfd, buff, strlen(buff), 0);
      |              ^~~~~~

я думаю, что все эти ошибки идут из одной проблемы, но не могу понять откуда

  • Home
  • Forum
  • The Ubuntu Forum Community
  • Ubuntu Specialised Support
  • Development & Programming
  • Packaging and Compiling Programs
  • [SOLVED] Compiling error ‘strlen’ was not declared in this scope

  1. Compiling error ‘strlen’ was not declared in this scope

    So I found out about Makehuman two days ago and thought how much this would help me with making models and the like, so I install the 1.0 Alpha 5 build (deb) and all was working fine until I tried to import a dae from MH to blender I keep getting this Python script error, so I try the mhx format from MH and it works, but, BAM, no edit mode. So I look around for tuts on how to fix these errors, but, none of them have anything to do with my problem at all so I decide to go back to a version that has been tested and that was 0.9.1 rc1. But here, I have to say, google failed be, I have honestly googled the mess out of my computer, here is the error I get

    Code:

    make[2]: Entering directory `/home/anon/Desktop/animorph-0.3/src'
    /bin/bash ../libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..    -Wall -g -O2 -MT BodySettings.lo -MD -MP -MF .deps/BodySettings.Tpo -c -o BodySettings.lo BodySettings.cpp
     g++ -DHAVE_CONFIG_H -I. -I.. -Wall -g -O2 -MT BodySettings.lo -MD -MP -MF .deps/BodySettings.Tpo -c BodySettings.cpp  -fPIC -DPIC -o .libs/BodySettings.o
    BodySettings.cpp: In member function 'void Animorph::BodySettings::fromStream(std::ifstream&)':
    BodySettings.cpp:54: error: 'strlen' was not declared in this scope
    make[2]: *** [BodySettings.lo] Error 1
    make[2]: Leaving directory `/home/anon/Desktop/animorph-0.3/src'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/anon/Desktop/animorph-0.3'
    make: *** [all] Error 2

    What I did was look for

    Code:

    'strlen' was not declared in this scope

    but to no avail then I looked for

    Code:

    BodySettings.cpp:54: error: 'strlen' was not declared in this scope

    and again nothing, the closest I got to solving this problem was this link which led me to this link but the first one does not, to my knowledge, explain how, as in what has to be done in the terminal or folder, to get past this. I have been trying to compile this for four days, all the while googling the problem and trying different links but most don’t even get a response (others that had this problem and posted) and the ones that do are way above my current level of understanding of ubuntu. It’s not through lack of trying that I am not able to understand it just is not clicking what it is I have to do. Any help would be greatly appreciated.

    Last edited by royevans; June 20th, 2010 at 01:20 AM.

    Karera ga kirai, kika sete nagai ma, karera wa osorete


  2. Re: Compiling error ‘strlen’ was not declared in this scope

    have you tried adding
    #include <cstring>
    to the .cpp file? sounds like its missing that header


  3. Re: Compiling error ‘strlen’ was not declared in this scope

    actually having a look at makehuman, it seems there is .deb files for ubuntu to download and even a repository you can add. Unless you are really keen on compiling it yourself, using the repository would seem to be a good idea


  4. Re: Compiling error ‘strlen’ was not declared in this scope

    have you tried adding
    #include <cstring>
    to the .cpp file? sounds like its missing that header

    Now when you say that, do you mean all thirty-five of them or just one specific one?
    *I just looked at the error again and I see «BodySettings.cpp» I am going to try that.
    **Thanks, it gets me past that but then I run into this error

    Code:

    In file included from VertexVector.cpp:2:
    ../include/animorph/util.h: In function 'void Animorph::stringTokeni(const std::string&, const std::string&, T&)':
    ../include/animorph/util.h:169: error: 'atoi' is not a member of 'std'
    ../include/animorph/util.h:174: error: 'atoi' is not a member of 'std'
    make[2]: *** [VertexVector.lo] Error 1
    make[2]: Leaving directory `/home/anon/Desktop/animorph-0.3/src'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/anon/Desktop/animorph-0.3'
    make: *** [all] Error 2

    Quote Originally Posted by SevenMachines
    View Post

    actually having a look at makehuman, it seems there is .deb files for ubuntu to download and even a repository you can add. Unless you are really keen on compiling it yourself, using the repository would seem to be a good idea

    I have tried the 1.0 Alpha X Makehuman debs as well as the 9.0 deb but none of them work how other’s work, the Collada export always errors out but I figured out the one I have yet to try was the 9.1 rc1 version which is the one that many many MANY tutorials use.

    Last edited by royevans; June 20th, 2010 at 05:53 PM.

    Karera ga kirai, kika sete nagai ma, karera wa osorete


  5. Re: Compiling error ‘strlen’ was not declared in this scope

    util.h needs
    #include <cstdlib>


  6. Re: Compiling error ‘strlen’ was not declared in this scope

    Quote Originally Posted by SevenMachines
    View Post

    util.h needs
    #include <cstdlib>

    This is indeed get me past my little problem, thank you, however, i decided to grow some balls and try the nightly build along with the 2.5 Alpha of blender, which works like a charm. I will move this thread to solved.

    Karera ga kirai, kika sete nagai ma, karera wa osorete


  7. Re: Compiling error ‘strlen’ was not declared in this scope

    Quote Originally Posted by royevans
    View Post

    This is indeed get me past my little problem, thank you, however, i decided to grow some balls and try the nightly build along with the 2.5 Alpha of blender, which works like a charm. I will move this thread to solved.

    What fixed it for me was adding include «string.h» in the files the error occured.
    In my case that was disco-matic .


Bookmarks

Bookmarks


Posting Permissions

Example

This error happens if a unknown object is used.

Variables

Not compiling:

#include <iostream>

int main(int argc, char *argv[])
{
    {
        int i = 2;
    }

    std::cout << i << std::endl; // i is not in the scope of the main function

    return 0;
}

Fix:

#include <iostream>

int main(int argc, char *argv[])
{
    {
        int i = 2;
        std::cout << i << std::endl;
    }

    return 0;
}

Functions

Most of the time this error occurs if the needed header is not
included (e.g. using std::cout without #include <iostream>)

Not compiling:

#include <iostream>

int main(int argc, char *argv[])
{
    doCompile();

    return 0;
}

void doCompile()
{
    std::cout << "No!" << std::endl;
}

Fix:

#include <iostream>

void doCompile(); // forward declare the function

int main(int argc, char *argv[])
{
    doCompile();

    return 0;
}

void doCompile()
{
    std::cout << "No!" << std::endl;
}

Or:

#include <iostream>

void doCompile() // define the function before using it
{
    std::cout << "No!" << std::endl;
}

int main(int argc, char *argv[])
{
    doCompile();

    return 0;
}

Note: The compiler interprets the code from top to bottom (simplification). Everything must be at least declared (or defined) before usage.

Tips: If you need C++ homework help from experts, you can always rely upon assignment helpers.

Понравилась статья? Поделить с друзьями:
  • Error led bus1f
  • Error keyring is not writable
  • Error keyframes not strictly monotonic increasing
  • Error keyboard при загрузке компьютера
  • Error key does not exist