- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
#include <stdio.h>
#include <stdlib.h>
#include <stdalign.h>
#include <inttypes.h>
#include <string.h>
float sum_f(const float arr[], const size_t len);
int32_t sum_i32t(const int32_t arr[], const size_t len);
#define sum(a, b) _Generic((a), float*: sum_f, \
const float*: sum_f, \
int32_t*: sum_i32t,\
const int32_t*: sum_i32t)(a, b)
// foldl (+) 0 arr
float sum_f(const float arr[], const size_t len)
{
return (len != 0) ? ( sum(arr+1, len-1) + arr[0] ) : 0;
}
int32_t sum_i32t(const int32_t arr[], const size_t len)
{
return (len != 0) ? ( sum(arr+1, len-1) + arr[0] ) : 0;
}
enum { we_want_int, we_want_float } what_we_want;
void test(int www)
{
void *a;
if (www == we_want_int)
{
uint8_t buf[sizeof(int32_t[10])] __attribute__ ((aligned (alignof(int32_t[10]))));
a = (void *) buf;
memcpy ( a, (int32_t[10]){1,2,3,4,5,6,7,8,9,10},
sizeof((int32_t[10]){1,2,3,4,5,6,7,8,9,10})
);
printf("%" PRIi32 "\n", sum((int32_t *)a, 10));
}
else if (www == we_want_float)
{
uint8_t buf[sizeof(float[10])] __attribute__ ((aligned (alignof(float[10]))));
a = (void *) buf;
memcpy ( a, (float[10]){1,2,3,4,5,6,7,8,9,10},
sizeof((float[10]){1,2,3,4,5,6,7,8,9,10})
);
printf("%f\n", sum((float *)a, 10));
}
}
int main(void)
{
test(we_want_int);
test(we_want_float);
return EXIT_SUCCESS;
}
Вот теперь всё работает, а точнее не работает:
https://ideone.com/u9pCcj
https://ideone.com/eWxpwe
https://wandbox.org/permlink/SgYTY1Tdwk6Ya4kd
Хотя в ELF (например) попытка изменения глобальных констант влечет неминуемый и неизбежный segfault.
Ага, попробуй сделать константу для float или double через этот enum (не говоря уж о всяких структурах, юнионах).
Тогда уж делайте константы через inline функции, типа
Даже вот так
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
pure
Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Calls to such functions can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pure. For example,
says that the hypothetical function square is safe to call fewer times than the program says.
Some common examples of pure functions are strlen or memcmp. Interesting non-pure functions are functions with infinite loops or those depending on volatile memory or other system resource, that may change between two consecutive calls (such as feof in a multithreading environment).
The pure attribute imposes similar but looser restrictions on a function’s defintion than the const attribute: it allows the function to read global variables. Decorating the same function with both the pure and the const attribute is diagnosed. Because a pure function cannot have any side effects it does not make sense for such a function to return void. Declaring such a function is diagnosed.
Many functions do not examine any values except their arguments, and have no effects except to return a value. Calls to such functions lend themselves to optimization such as common subexpression elimination. The const attribute imposes greater restrictions on a function’s definition than the similar pure attribute below because it prohibits the function from reading global variables. Consequently, the presence of the attribute on a function declaration allows GCC to emit more efficient code for some calls to the function. Decorating the same function with both the const and the pure attribute is diagnosed.
Note that a function that has pointer arguments and examines the data pointed to must not be declared const. Likewise, a function that calls a non-const function usually must not be const. Because a const function cannot have any side effects it does not make sense for such a function to return void. Declaring such a function is diagnosed.
https://ideone.com/Horidq
Наверное ты за Rust?
* Побочные эффекты: головная боль, тошнота, судороги, нарушения логического аппарата.
Язык, в котором можно смешивать древнее говно c тучей неявных переменных F77 с ООП из F2003 и встроенной параллелизацией F2008.
Ну я бы не сказал, что современный фортран примитивен. Интересно, а окамлобоги пробовали генерить фортран вместо сишки?
З.Ы. Иньо там умер или как?
Да всю правду доложи:
Кто баграми в сток хуярит?
Кто виаграми там спамит?
Лень думать. Ёбну все пробелы перед проверкой на виагру да и всё.
Разработать для этого DSL
ахаха, стабильненько, надежненько, ничего не скажешь
?
Я хз, вообще-то я малышка-скриптомартышка.
З.Ы. Тут еще и 2 зеркала есть...
buy cialis online!
http://onlinecialisurw.com/ , , http://viagraaqwe.com/ , , http://viagraaloq.com/ , , http://viagrapoie
Не, боты скорее всего читают страничку перед отправкой чтобы всякие csrf защиты пробивать. Т.е. куки у них тоже будут.
З.Ы. Ну разве что создавать куку из скрипта.
Иньо, заебал, блядь.
Блядь, Иньо, заебал.
Блядь, заебал, Иньо.
Заебал, Иньо, блядь.
Заебал, блядь, Иньо.
говно же
Там всего-то при объявлении класса знак "<" используется.
Передавай всю фигню через указатель в inline функцию - компилятор сам закложит как надо
> полиморфизм, vtbl, не?
Массив из указателей на функции, *void.
> абстракция стрима же с удобно перегруженым оператором левагосдвига?
Нет, мне неудобно.
> чтобы палучитьи тератор
Зачем он?
> ты каданито в сишечке строчки кокотенировал? приятно тебе было?
Да. Да.
> канструктор не вызываеца же, RAII, не?
Конструкторы - нинужно. malloc - всему голова. RAII - говно
https://govnokod.ru/24517
>> * 1. Do not use `return` from within `raii_with`, but only `safe_return`, because otherwise the destructors will not be run.
>> * 2. Do not perform pointer-swaps with `var_decl`; the destructor will still be run on the original structure, because `raii` keeps its own reference to the resource.
Обсракции текут из всех щелей. В жопу это говно, уж лучше через goto вручную пердолится.
Потому что перегрузка уже есть с незапамятных времён. Которая делает тоже самое, только лучше.
Такой убогий костыль, как сишный _Generic, ещё поискать надо. Это как strtok, только _Generic.
Особенно учитывая что в разных компиляторах разный манглинг, который еще иногда умудряются ломать https://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/
И учитывая то, что если надо вызвать замангленное крестоговно из какого-нибудь другого языка, приходится использовать разные костыли или руками эту парашу выписывать (для разных компиляторов разную)
Есть же - strtol, strtoll, strtoull, strtod, strtof.
_snwprintf_s_l
Манглинг - это самая тривиальная из проблем, возникающих при вызове крестоговна из других языков.
> roman-kashitsyn 22.01.2018 11:50
> Перегрузка — говно, я предпочитаю пользоваться специализацией шаблонов с дополнительной функцией-обёрткой. Жизнь слишком коротка, чтобы разобраться, как перегрузка функций работает с шаблонами функций.
Именно. Про lattice слышал?
_Generic ≤ overloading ≤ template specialization
I've hungered for your touch
A long lonely time
And time goes by so slowly
And time can do so much
Are you still mine?
I need your love
I need your love
God speed your love to me
Lonely rivers flow to the sea to the sea
To the open arms of the sea
Lonely rivers sigh wait for me wait for me
I'll be coming home wait for me
Oh, my love, my darling,
I've hungered hungered for your touch
A long lonely time
And time goes by so slowly
And time can do so much
Are you still mine?
I need your love
I need your love
God speed your love to me
За тунеядство был осужден,
Лауреатом стал Иосиф Бродский,
И чек в Стокгольме ему вручен!
Херлуф Бидструп, Херлуф Бидструп,
Нарисуй мне мой портрет!
Херлуф Бидструп, Херлуф Бидструп,
Художника лучше нет!
Летчик, летчик, посади самолет!
Летчик, летчик, там любовь меня ждет!
Летчик, летчик, мимо не пролети!
Летчик, летчик, самолет посади!
Доктор Ватсон и доктор Живаго,
Поскорее мне дайте ответ,
Доктор Ватсон и доктор Живаго,
Скоро встречу любовь или нет?
Альтист Данилов, ты – музыкант!
Альтист Данилов, храни талант!
Кто ты, Альтист Данилов, демон или человек?
Альтист Данилов... Со мной навек!
Я – Собчак, я – Собчак, попрошу не путать!
Я – Собчак, я – Собчак, Петербурга мэр!
Я – Собчак, я – Собчак, могут ведь напутать –
Скажут, он, мол, не Собчак вовсе, а Колчак!
Дай мне, зайцыще, ногою в яйцыще,
Огромной ножищей дай мне, дай!
Прямо в яйцыще огромной ножищей,
Старый зайцыще, дай мне, дай!
Ведь ты же так красива в свои восемнадцать.
Какое SEO )))
>>> RU
>>> васил троянов боянов умер
Какой багор (((