Показаны сообщения с ярлыком error. Показать все сообщения
Показаны сообщения с ярлыком error. Показать все сообщения

понедельник, 31 марта 2014 г.

Немного установки php

  Configuration File (php.ini) Path => /etc/php5/apache2
  Loaded configuration file => (none)

Если php в упор не видит свой ini file, хотя при компиляции ему ясно указали
  --with-config-file-path=/etc/php5/php.ini
то все просто, надо указывать папку, а не сам файл. Как-то так:
  --with-config-file-path=/etc/php5
и тогда он сам найдет там php.ini

среда, 12 февраля 2014 г.

В mysql записываются знаки вопроса вместо русского

Внезапно, встретился с такой проблемой. Из c++ передавался русский в кодировке windows-1251, таблица - cp1251_general_ci, а записываются все равно ????? Решение оказалось просто - надо после установки соединения 1 раз вызвать:
  mysql_query(conn, "SET NAMES cp1251");

среда, 29 января 2014 г.

MYSQL таблица MEMORY ограничена в размере и не заполняется

При тестах понадобилось создать таблицу типа MEMORY и оказалось, что необходимый объем данных не влезает. Выше определенного числа строки просто не создаются с ошибкой:
The table НАЗВАНИЕ ТАБЛИЦЫ is full

По факту - у MYSQL просто кончилась память под размещение данных в куче. Легко изменить это в настройках MYSQL (в Linux - по умолчанию /etc/my.cnf):
max_heap_table_size=256M

среда, 8 февраля 2012 г.

Segmentation fault при создании большого массива

При выполнении программы вида:
int main()
{
   int c[1000000];
   cout << "done\n";
   return 0;
}
можно получить ошибку Segmentation fault.
Это связано с переполнением стека. Локальные переменные хранятся в стеке, и там не хватает места на массив c[1000000].
Решение - выделять память из кучи.
Например, int* array = new int[1000000]; Тогда надо не забыть вызвать delete[] после этого.
 Источник - см. тут.

вторник, 18 октября 2011 г.

undefined reference to `vtable for


КОД
class A {
public:
  A() {
    // ...
  };
  // имеет виртуальные функции
}

class B : public A {
public:
  B() : A() {
    // ...
  }
  // определяет все виртуальные функции класса А
}


но после успешной компиляции при linkage получаю:

filename.o:filename.cpp:(.text+0x8) undefined reference to `vtable for A`


Обычно это происходит, если какой-то виртуальный метод класса объявлен, но нигде не определён. g++ обычно помещает vtable только в тот объектный файл, где определяется первый виртуальный метод класса, не объявленный как inline


Либо определяем здесь же реализацию виртуальных функций, либо делаем их "чистыми", помечая спецификатором "чистоты" - "=0"


Материал отсюда

error: there are no arguments to '' that depend on a template parameter, so a declaration of '' must be available

Когда получаешь error: there are no arguments to 'XXX' that depend on a template parameter, so a declaration of 'XXX' must be available. Это значит в шаблонном классе была вызвана не шаблонная функция.
Решение - явно указать Класс::XXX или включить функцию в namespace
Подробнее(отсюда):



There are no arguments to 'X' that depend on a template parameter, so a declaration of 'X' must be available
Aside: I have a C++ prograof moderate complexity that I have to return to every 12-18 months to fix an obscure bug or add a modest festure.And every time, I spent one or two days just trying to get the thing build with the latest compiler, which picks up previously legal code and decides to whine about it, generating dozens of errors.
This is not the fault of the compiler. This is the fault of C++ for being so sloppy and complex. This is why C++ should just die and give watoJava.

The Error

Compiling a templated class that "worked previously" (under gcc3.3. as opposed to 4.x), an error was thrown on a previously acceptable andnon-templated member:
/Users/agapow/Desktop/mloc/ComboMill.h:188: error: there are no arguments to 'SetMemberShip'
that depend on a template parameter, so a declaration of 'SetMemberShip' must be available
Huh. A simplfied version of the class looks like this:
template  class ComboMill
{
 // ...
 
 void SetMembership (bool iIsMember)
 {
  for (int i = 0; i < mMembership.size(); i++)
  {
   mMembership[i] = iIsMember;
  }
 }
 
 void First ()
 {
  // error on next line
  SetMembership (false);
 }

 // ...
};
SetMembership is called by a numbeof other methods to toggle the state of set members. But that isn't the problem - the problem occurs where other methods go to call SetMembership.

Solution

It'a tough error to google for, but basically C++ is being stricter about how it identifies what you are calling. Where previously a symbol "X" would be implicitly taken to refer to a member or method "X" on the parent class, here C++ is insisting that you make it explicit. Thus it can easily be fixed by writing:
void First ()
 {
  // error on next line
  this->SetMembership (false);
 }

 // ...
};
Onof the criticisms made about Python is that you have to explicitly membeaccess qualify with "self". It seems C++ is also not longer immune form this.