size_t не может быть найден g ++-4.1 или другими на Ubuntu 8.1

К сожалению, я неспособен получить менее чем тысячу слов...

alt text

(LabVIEW. Да, они позволят примерно любому сообщению бродяги здесь;)

10
задан Evan Teran 18 July 2009 в 18:49
поделиться

6 ответов

Начните с удаления -I / usr / include / linux и -I / usr / include. Добавление системных каталогов для включения путей вручную либо не имеет никакого эффекта, либо нарушает работу. Также удалите -frepo для дополнительной безопасности.

9
ответ дан 3 December 2019 в 16:54
поделиться

Generally, you shouldn't be using C .h files for C++. While you may find an easy way to get away with it, and while a lot of this was allowed in previous versions of g++ and in other compilers, the C++ standard defines size_t to be in cstddef (see section 18.2/table 17). g++ has been only getting more strict.

Remove all the includes paths you've added to your command (they are redundant), and add to the top of your source code if not included:

#include <cstddef>
using namespace std;
4
ответ дан 3 December 2019 в 16:54
поделиться

It's hard to say what the issue is without seeing your complete source. The best way to debug issues like this is to use g++'s "-E" parameter to produce pre-processor output, and then look at that to figure out what's going on in your includes. Here's what the g++ info page says about "-E":

-E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output.

Also, why not just include sys/types.h at the top of the file?

Addendum:

On my system, I've created a short file called foo.cc that contains only:

#include <time.h>

And then I've run:

g++ -E /tmp/foo.cc > /tmp/foo.pp

Looking at this output in much detail is very important. For example, I learned that /usr/include/bits/types.h has a typedef for __time_t, and that /usr/include/types.h then uses that typedef to say "typedef __time_t time_t". But, there are interesting other macros surrounding that definiton. Pay special attention to things like the macro "__BEGIN_NAMESPACE_STD" in /usr/include/time.h, which on my system seems to be an empty define. But, I can imagine that some other systems may have a different value for this macro, forcing the definition of time_t into some other namespace.

Read the Cpp info page, section "9 Preprocessor Output" that defines the format of the lines of the file. Of particular note is the section on:

Source file name and line number information is conveyed by lines of the form

# LINENUM FILENAME FLAGS

And then goes on to describe "FLAGS" which are of interest for this level of debugging.

4
ответ дан 3 December 2019 в 16:54
поделиться

Вы установили пакет build-essential?

sudo apt-get install build-essential
3
ответ дан 3 December 2019 в 16:54
поделиться

Он должен быть в stddef.h или cstddef. types.h не является стандартной библиотекой, и я считаю, что она относится к типам, которые нужны ОС.

1
ответ дан 3 December 2019 в 16:54
поделиться

Забыл следить за этим. Оказывается, / usr / include нельзя включить в / usr / include / linux в этом конкретном дистрибутиве. size_t , кажется, будет уничтожен вторым включением.

Мои включения теперь просто / usr / include , и он отлично работает.

-I/usr/include -I/usr/include/ace -I/usr/lib/glib-2.0/include -I/usr/include/glib-2.0...

Удаление всех включений и игра с ними исправила это.

3
ответ дан 3 December 2019 в 16:54
поделиться
Другие вопросы по тегам:

Похожие вопросы: