added QSE_ALIGNOF().
This commit is contained in:
parent
df28fde9ef
commit
1f9de59543
@ -119,7 +119,7 @@
|
||||
#define QSE_SIZEOF(n) (sizeof(n))
|
||||
|
||||
/**
|
||||
* The QSE_COUNTOF() macro gets the number elements in a array.
|
||||
* The QSE_COUNTOF() macro returns the number elements in an array.
|
||||
* The following code snippet should print 128.
|
||||
* @code
|
||||
* int x[128];
|
||||
@ -129,16 +129,24 @@
|
||||
#define QSE_COUNTOF(n) (sizeof(n)/sizeof(n[0]))
|
||||
|
||||
/**
|
||||
* The QSE_OFFSETOF() macro get the offset of a fields from the beginning
|
||||
* The QSE_OFFSETOF() macro returns the offset of a field from the beginning
|
||||
* of a structure.
|
||||
*/
|
||||
#define QSE_OFFSETOF(type,member) ((qse_size_t)&((type*)0)->member)
|
||||
#define QSE_OFFSETOF(type,member) \
|
||||
((qse_size_t)&((type*)0)->member)
|
||||
|
||||
/**
|
||||
* The QSE_ALIGNOF() macro returns the alignment size of a structure.
|
||||
* Note that this macro may not work reliably depending on the type given.
|
||||
*/
|
||||
#define QSE_ALIGNOF(type) QSE_OFFSETOF(struct { qse_uint8_t d1; type d2 }, d2)
|
||||
/*(sizeof(struct { qse_uint8_t d1; type d2 }) - sizeof(type))*/
|
||||
|
||||
/**
|
||||
* The QSE_TYPE_IS_SIGNED() macro determines if a type is signed.
|
||||
* @code
|
||||
* printf ("%d\n", QSE_TYPE_IS_SIGNED(int));
|
||||
* printf ("%d\n", QSE_TYPE_IS_SIGNED(unsigned int));
|
||||
* printf ("%d\n", (int)QSE_TYPE_IS_SIGNED(int));
|
||||
* printf ("%d\n", (int)QSE_TYPE_IS_SIGNED(unsigned int));
|
||||
* @endcode
|
||||
*/
|
||||
#define QSE_TYPE_IS_SIGNED(type) (((type)0) > ((type)-1))
|
||||
|
@ -1,3 +1,23 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <qse/cmn/alg.h>
|
||||
|
||||
/* Park-Miller "minimal standard" 31 bit
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include <qse/cmn/fio.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
|
||||
#define R(f) \
|
||||
do { \
|
||||
@ -81,13 +79,6 @@ static int test1 (void)
|
||||
|
||||
int main ()
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
qse_printf (QSE_T("Set the environment LANG to a Unicode locale such as UTF-8 if you see the illegal XXXXX errors. If you see such errors in Unicode locales, this program might be buggy. It is normal to see such messages in non-Unicode locales as it uses Unicode data\n"));
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
|
||||
R (test1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -62,7 +62,6 @@ oops:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
return qse_runmain (argc, argv, sed_main);
|
||||
|
Loading…
Reference in New Issue
Block a user