Sponsored Content
Top Forums Programming Help me to understand strange 'typedef ... ' in some source... Post 302983612 by jim mcnamara on Thursday 13th of October 2016 09:51:09 PM
Old 10-13-2016
That is a typedef of a function. In this case the need was for portability -windows compiler versus maybe a linux C compiler.
No dataype declaration for the function. So, by default, the function will compile probably with a warning as a function that returns an integer.

So you do not worry about the platform, you will notice void * arguments. This lets you call COMPARE_ADDR with any datatypes as long as those datatypes are by reference (address of the object). It does not have a datatype for the function return. This kind of function typedef is usually done for situations where you want to call something to get a standard result, but windows and linux (example platform) do not have the same name for the function, but it may return { <0, 0, >0} for less than, equal to, or greater than.

Pretend example
Code:
#ifdef WIN32 
   COMPARE_ADDR=isequal;
#else
   COMPARE_ADDR=addr_foo;
#endif
/* see if the memory location of two variables is the same */
if  ( ! COMPARE_ADDR( &variable3, &variable1) {  /* if equal barf */
    errno=EINVAL;  /* invalid value error code */
    perror("Cannot continue, variables are identical and must not be identical\n");
    exit(1);   /* end program here */
}


Last edited by jim mcnamara; 10-13-2016 at 11:00 PM..
 

9 More Discussions You Might Find Interesting

1. Solaris

Conflicting 'typedef' error - Which gcc switch to use?

I am using gcc3.3.5 on solaris2.7. Its a 64 bit compilation I am compiling a file 'plugin.cpp'. It includes mach.h and the complation gives the following error. ----------------------------------------------------------------- mach.h error: conflicting types for `typedef vx_u32_t... (0 Replies)
Discussion started by: amitc
0 Replies

2. Programming

How to typedef

I want to declare char ch as ch_9 with the help of the typedef statement. Thanks (1 Reply)
Discussion started by: krishna_sicsr
1 Replies

3. Shell Programming and Scripting

bash shell: 'exec', 'eval', 'source' - looking for help to understand

Hi, experts. Whould anybody clear explay me difference and usage of these 3 commands (particulary in bash) : exec eval source I've tryed to read the manual pages but did not get much. Also could not get something useful from Google search - just so much and so not exactly, that is... (3 Replies)
Discussion started by: alex_5161
3 Replies

4. Programming

typedef struct forward declaration

I've google a bit about this and couldn't find an answer. Actually I read that it can't be done. Basically I've defined the following structure and typedef it as follows. stuct Name { }; typdef struct Name Name. and right after it, defined some API that use it. void blabla(Name*... (6 Replies)
Discussion started by: emitrax
6 Replies

5. Programming

Need help with this c++ source code! DOnt understand what some stuff mean.

Okay so I am just starting programming c++. I just started started to red "C++ for Dummies yesterday and theres a lot of things I do not understand from this book and this source code especially. I will first post the full source code and then post questions about certain thing, usually what they... (2 Replies)
Discussion started by: orszhak
2 Replies

6. Programming

typedef help

Hi! This is part of my my code : typedef struct{ int x; char na; char sur; } Stu; typedef struct{ Stu *arr; int size; int sort; } Stus; I want to ask how can i free() the matrix arr. I tried free(arr), free(Stus.arr) and i get errors with gcc. My problem, in... (3 Replies)
Discussion started by: giampoul
3 Replies

7. Programming

Compilation problem with typedef

I am getting confused compiling a program that gives me the following error ../../../tomso/algeb/vector.hpp:19:9: error: ‘Vector' does not name a type typedef Vector<float> Vecflt; (1 Reply)
Discussion started by: kristinu
1 Replies

8. Programming

Event driven programming / epoll / typedef union / session data array

Sorry for the “word salad” subject, but I wanted to cast a wide net for help. I've created an IP (Internet Protocol) server which serves HTTP, SMTP, and FTP requests. As you probably know, they all require creating a socket, listening on it, accepting connections, and then having a short... (3 Replies)
Discussion started by: John S.
3 Replies

9. Programming

Typedef does not work to name a type

Hello, This is related to the closed post in the forum for the installation of the same software called arachne, but with different error message: In file included from ueberal/MiniSuperizer.cc:5:0: ./random/GnuRandom.h:54:5: error: ‘_G_uint32_t’ does not name a type _G_uint32_t u; ^... (11 Replies)
Discussion started by: yifangt
11 Replies
uic(1)							      General Commands Manual							    uic(1)

NAME
uic - Qt user interface compiler SYNOPSIS
uic [options] file DESCRIPTION
This page documents the User Interface Compiler for the Qt GUI toolkit. The uic reads a user interface definition (.ui) file in XML as gen- erated by Qt Designer and creates corresponding C++ header or source files. It also generates an image file that embeds raw image data in C++ source code. Generate declaration: uic [options] <file> Generate implementation: uic [options] -impl <headerfile> <file> <headerfile>: name of the declaration file Generate image collection: uic [options] -embed <project> <image1> <image2> <image3> ... <project>: project name <image[1..n]>: image files For convenience, uic can also generate declaration or implementation stubs for subclasses. Generate subclass declaration: uic [options] -subdecl <subclassname> <baseclassheaderfile> <file> <subclassname>: name of the subclass to generate <baseclassheaderfile>: declaration file of the baseclass Generate subclass implementation: uic [options] -subimpl <subclassname> <subclassheaderfile> <file> <subclassname>: name of the subclass to generate <subclassheaderfile>: declaration file of the subclass GENERAL OPTIONS
-o file Write output to file rather than to stdout. -nofwd Omit forward declarations of custom classes in the generated header file. This is necessary if typedef classes are used. -tr func Use func() instead of tr() for internationalization. -version Display the version of uic and exit. USAGE
uic is almost always invoked by make(1), rather than by hand. Here are useful makefile rules if you only use GNU make: %.h: %.ui uic $< -o $@ %.cpp: %.ui uic -impl $*.h $< -o $@ If you want to write portably, you can use individual rules of the following form: NAME.h: NAME.ui uic $< -o $@ NAME.cpp: NAME.ui uic -impl $*.h $< -o $@ You must also remember to add NAME.cpp to your SOURCES (substitute your favorite name) variable and NAME.o to your OBJECTS variable. (While we prefer to name our C++ source files .cpp, the uic doesn't care, so you can use .C, .cc, .CC, .cxx or even .c++ if you prefer.) SEE ALSO
http://www.trolltech.com/ AUTHOR
Trolltech ASA <info@trolltech.com> Trolltech AS 2 Aug 2001 uic(1)
All times are GMT -4. The time now is 01:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy