Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

scorpio

typedef redefinition

Recommended Posts

Fala minha gente!

 

 

Estou com um probleminha aqui a mais de uma semana já.

 

Estou tentando utilizar parte de um projeto do CodeProject, no meu.

 

Tenho dois typedef:

 

typedef struct _IO_STATUS_BLOCK { 
NTSTATUS Status; 
ULONG Information; 
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; 


typedef enum _FILE_INFORMATION_CLASS {


    FileDirectoryInformation=1,
    FileFullDirectoryInformation,
    FileBothDirectoryInformation,
    FileBasicInformation,
    FileStandardInformation,
    FileInternalInformation,
    FileEaInformation,
    FileAccessInformation,
    FileNameInformation,
    FileRenameInformation,
    FileLinkInformation,
    FileNamesInformation,
    FileDispositionInformation,
    FilePositionInformation,
    FileFullEaInformation,
    FileModeInformation,
    FileAlignmentInformation,
    FileAllInformation,
    FileAllocationInformation,
    FileEndOfFileInformation,
    FileAlternateNameInformation,
    FileStreamInformation,
    FilePipeInformation,
    FilePipeLocalInformation,
    FilePipeRemoteInformation,
    FileMailslotQueryInformation,
    FileMailslotSetInformation,
    FileCompressionInformation,
    FileCopyOnWriteInformation,
    FileCompletionInformation,
    FileMoveClusterInformation,
    FileQuotaInformation,
    FileReparsePointInformation,
    FileNetworkOpenInformation,
    FileObjectIdInformation,
    FileTrackingInformation,
    FileOleDirectoryInformation,
    FileContentIndexInformation,
    FileInheritContentIndexInformation,
    FileOleInformation,
    FileMaximumInformation


} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;

Mas, aqui começam os problemas. Quando eu mando compilar me aparecem dois erros de 'redefinition'!

error C2011: '_FILE_INFORMATION_CLASS' : 'enum' type redefinition

error C2011: '_IO_STATUS_BLOCK' : 'struct' type redefinition

 

Ok, apareceu esse erro, retirei o typedef e compilei. Mas ai deu erro por não ter o maldito typedef.

Se eu coloco dá redefinition, se eu tiro fala que não tem.

 

Outro erro que acontece é nesse outro typedef:

typedef struct _LSA_UNICODE_STRING {
    USHORT        Length;
    USHORT        MaximumLength;
    PWSTR        Buffer;
} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING, UNICODE_STRING, *PUNICODE_STRING;
error C2371: 'UNICODE_STRING' : redefinition; different basic types

error C2371: 'PUNICODE_STRING' : redefinition; different basic types

 

Já tentei mudar o nome dos tipos ali mas não adiantou.

 

 

Estou usando o Visual Studio 2008 pra compilar. É só C++, não tem nada de .Net.

 

Não manjo muito de C++, mas já procurei em vários lugares e não encontrei muita coisa...

O redefition acho que pode ser alguma include em algum header que já tenha o typedef, mas não tenho certeza.

 

 

Se alguém puder me indicar o caminho...

 

 

Valeu!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Então, EU mesmo não.

Deve ter alguma coisa do Windows.

 

Mas se eu tiro a MINHA referencia, e tento dar um GOTO DEFINITION, o Visual Studio trava porque não acha a definição, porque não tá, definido. =/

Compartilhar este post


Link para o post
Compartilhar em outros sites

Se você tentar mudar o nome de tudo, ele da o mesmo erro?

E se você mudar o jeito que faz o typedef, tipo assim: http://stackoverflow.com/questions/707512/typedef-enum-in-objective-c

 

acho que da pra gente ir cercando o erro para tentar solucionar.

 

[]s

Compartilhar este post


Link para o post
Compartilhar em outros sites

Vou mostrar a estrutura que estão os arquivos.

 

PUNICODE_STRING, FILE_INFORMATION_CLASS, PIO_STATUS_BLOCK estão dentro do Winternl.h incluído no MAIN.

No arquivo MAIN, eu utilizo esses tipos sem problemas... apenas com o include.

 

 

 

Arquivo main.cpp

#pragma once
...
#include "FileHideAlgorithm.h"
...
#include <windows.h> 
#include <Winternl.h>

Arquivo FileHideAlgorithm.h

#pragma once

#include "IFileChecker.h"

Arquivo IFileChecker.h

#pragma once


typedef unsigned char BYTE;
typedef BYTE BOOLEAN;
typedef void *HANDLE;
typedef void *PVOID;
typedef long  NTSTATUS; 
typedef unsigned long ULONG;
typedef unsigned short USHORT;
typedef wchar_t *PWSTR;

typedef struct _IO_STATUS_BLOCK { 
NTSTATUS Status; 
ULONG Information; 
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; 


typedef struct _LSA_UNICODE_STRING {
    unsigned short Length;
    unsigned short MaximumLength;
    wchar_t        *Buffer;
} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING, UNICODE_STRING, *PUNICODE_STRING;


typedef enum _FILE_INFORMATION_CLASS {...} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;


namespace HideAlgorithm
{
	struct NtQueryDirParams
	{
		...
	};

	struct IFileChecker
	{
		virtual bool 
		CheckFile( wchar_t* fileName
				 , size_t nameSize
				 , const NtQueryDirParams& params )=0;
	};
}
O que eu pensei que pudesse ser, é que como o IFileChecker.h está "abaixo" do main.cpp que contém o Winternl.h, ele estaria "pegando" as referencias do main.cpp. Mas não é porque quando eu tiro MINHAS definições continuam os erros...

 

 

 

Se eu mudar o nome, "aparentemente" funcionou. Sumiram os erros de redefinition. Mas, por exemplo, a struct NtQueryDirParams utiliza um PUNICODE_STRING, que passou a se chamar X.

typedef struct _LSA_UNICODE_STRING {
    USHORT Length;
    USHORT MaximumLength;
    PWSTR  *Buffer;
////} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING, UNICODE_STRING, *PUNICODE_STRING;
} Y, *R, V, *X;

Em outra parte do programa, eu utilizo essa struct mas ela espera por PUNICODE_STRING, por que pega a definição do Winternl.h.

Não sei se deu pra entender, mas seria assim, em partes diferentes do programa eu usaria a struct com atributos de tipo diferente.

 

 

Se eu retiro essas definições e adiciono a referencia Winternl.h, não funciona do mesmo jeito... =/

 

Tentei mudar as definições como no link que você passou, mas também não funcionou...

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.