Why is it when i do the following i get errors when relating to with wchar_t?
namespace Foo
{
typedef std::wstring String;
}
Now i declare all my strings as Foo::String through out the program, but when i ever attempt to create a new Foo::String from a wchar_t* i get an error, e.g.:
namespace Bar
{
static const wchar_t* COMMON...
Dear all!
I am not too familiar with C programming, and I have to do few modifications on a source code, here is the problem:
I have this in a header file :
typedef struct word {
long wnum;
float weight;
} WORD;
typedef struct svector {
WORD *words;
double norm;
} SVECTOR;
In my file.c , I have a function like
doubl...
I am trying to do something like this:
template <typename T,bool Strong=true>
class Pointer {...};
template <typename T>
typedef Pointer<T,false> WeakPointer;
But this is a compile error ("a typedef template is illegal" VC).
I am trying to avoid doing this using inheritance, beacuse that's more unnecessary work (rewriting constructo...
Hi everyone,
I am working on a C++ project on macOS X 10.6.2 with xcode.
I tried to compile my code on windows and do not have any problem, I guess Linux is working but I don't have one with me right now.
My problem is xcode do not accept this kind of instruction :
struct direction {
double x;
double y;
double z;
double t; };
typede...
And if so, why some Win32 headers use it?
For instance:
BOOL APIENTRY VerQueryValueA( const LPVOID pBlock,
LPSTR lpSubBlock,
LPVOID * lplpBuffer,
PUINT puLen
);
A bit more elaboration: If the API never uses references (or any other C++-only constructs) but only pointers and values, what is the point of having const L...
In a .cpp file, is there any difference/preference either way?
// file scope outside any namespace
using X::SomeClass;
typedef SomeClass::Buffer MyBuf;
v/s
namespace { // anonymous
using X::SomeClass;
typedef SomeClass::Buffer MyBuf;
}
...
I'm working on some ActionScript code that needs to juggle a bunch of similar-but-not-interchangeable types (eg, position-in-pixels, internal-position, row-and-column-position) and I'm trying to come up with a naming scheme to minimize the complexity.
Additionally, I don't yet know what the best format for the "internal position" is – u...
What are some of the best ways to manage redundant typedefs used for platform independence from multiple middleware (operating systems, protocol stacks) vendors in the C programming language.
e.g.:
target.h
/* inclusion lock etc */
typedef char CHAR;
typedef unsigned char BYTE;
typedef unsigned short int WORD;
/* ... more of the same ....
Going by gcc version 4.4.2, it appears that saying
typedef struct foo foo;
// more code here - like function declarations taking/returning foo*
// then, in its own source file:
typedef struct foo
{
int bar;
} foo;
is legal in C++ but not in C.
Of course I have a body of code that compiles fine in C++ by using the foo type but it ...
How come I can't instantiate an object of type Foo with above constructor?
I have a class Bar that uses an internal typedef (as a workaround for "template typedefs") and intend to use it in a constructor as below (CASE 1).
However, I don't seem to get it to compile. Is this legal C++?
CASE 2 seems to suggest the problem is related to th...
The following line of code compiles just fine and behaves:
list<const int *> int_pointers; // (1)
The following two lines do not:
typedef int * IntPtr;
list<const IntPtr> int_pointers; // (2)
I get the exact same compile errors for
list<int * const> int_pointers; // (3)
I'm well aware that the last line is not legal since the...
I'm trying to use forward declarations and d-pointers to eliminate some include dependencies. Everything is working well, except that I have used XList typedefs for readability in many places (e.g: typedef QList<X> XList).
The workaround for the typedef forward declaration issue is to use inheritance: class XList : public QList<X>{};.
...
Hi all.
I have a function in C++ that I call with its memory address with typedef, and I want to do the same thing in Delphi.
typedef void (*function_t)(char *format, ...);
function_t Function;
Function = (function_t)0x00477123;
And then, I call it with: Function("string", etc);
I tried to do this in Delphi, but got no results.
I...
It's possible to use @TypeDefs annotation to define short type name for a UserType. But how to define it for entire application?
...
I'm trying to automatically resolve typedefs in arbitrary C++ or C projects.
Because some of the typedefs are defined in system header files (for example uint32), I'm currently trying to achieve this by running the gcc preprocessor on my code files and then scanning the preprocessed files for typedefs. I should then be able to replace t...
Hi,
I'm currently using something like that in my code:
class B : public A<C> { };
Wouldn't it be better to use a typedef?
typedef A<C> B;
...
Lately I've run into the following construction in the code:
typedef sometype sometype;
Pay attention please that "sometype" stands for absolutely the same type without any additions like "struct" etc.
I wonder what it can be useful for?
UPD: This works only for user defined types.
UPD2: The actual code was in a template context l...
If I have the following:
typedef struct _MY_STRUCT
{
int a;
float b;
} MY_STRUCT, *PMYSTRUCT
What does *PMYSTRUCT do? Is it now a pointer type which I need to declare or just a pointer to _MY_STRUCT which I can use?
I know that MY_STRUCT is a new type that needs to be used as follows:
MY_STRUCT str;
str.a = 2;
But what abou...
I have a templated class
template <T>
class Example
{
...
};
inside which there
are many methods of the following type:
template <class U> <class V> method(....)
Inside these I use tr1::shared_ptr to U or V or T.
Its tedious typing tr1::shared_ptr<const U> or tr1::shared_ptr<const V>.
The obvious thing to do:
template <typenam...
Hi,
I have a class looking like this:
#include <vector>
#include "record.h"
#include "sortcalls.h"
template<
typename T,
template<typename , typename Allocator = std::allocator<T> > class Cont = std::vector>
class Sort: public SortCall {
This code is working and I'm calling it like this from other classes:
Comparator c; // c...