В чем тут фокус?
std::tm
-- это завёрнутая в namespace std struct tm
, древняя структура из чистого C. #include <time.h>
enum time_floor_level {
YEAR, MONTH, DAY, HOUR, MINUTE,
};
time_t time_floor(time_t t, enum time_floor_level level)
{
struct tm tm;
gmtime_r(&t, &tm);
switch (level) {
case YEAR:
tm.tm_mon = 0;
case MONTH:
tm.tm_mday = 1;
case DAY:
tm.tm_hour = 0;
case HOUR:
tm.tm_min = 0;
case MINUTE:
tm.tm_sec = 0;
}
return timegm(&tm);
}
Что означает ошибка «Error: relocation ... cannot be used with -shared»
gcc -fpic
). Из-за того что динамические библиотеки могут быть загружены в процесс по любому адресу существует требование, что код в них должен быть position-independent. Поэтому объектники скомпилированные как position-dependent обычно не могут быть слинкованы в динамическую библиотеку. R_AARCH64_TLSLE_ADD_TPREL_HI12
говорит (частью TLSLE, где LE означает Local Executable) о том, что код объектника в котором она находится был намеренно собран с рассчётом на то, что объектник будет частью исполняемого файла, а не динамической библиотеки. Здесь можно почитать об отличиях моделей адресации TLS, в частности о модели Local Exec в разделе 4.4. Почему возникает проблемы при закрытие файла
Больших отличий я не заметил
while (num_bor_1 <= num_bor_2)
{
if ((num_bor_1 % 2) != 1)
{
num_bor_1++;
}
}
do
{
num_bor_1++;
} while (num_bor_1 < num_bor_2);
Почему возникает free(): double free detected
String
копия получает то же значение str
что и оригинал с которого она скопирована, в деструкторе копия удаляет str
оригинала, а потом это же делает оригинал в своём деструкторе. См. правило трёх/пяти. IStream
который возвращает эта функция. third = string(buffer1);
fourth = string(buffer2);
third = string(buffer1, size3);
fourth = string(buffer2, size4);
char buffer1[size3];
…
char buffer2[size4];
wcout << endl << "Результат: " << encrypt(s);
Mixing operations on corresponding wide- and narrow-character streams follows the same semantics as mixing such operations on FILEs, as specified in the C standard library.
Each stream has an orientation. After a stream is associated with an external file, but
before any operations are performed on it, the stream is without orientation. Once a wide
character input/output function has been applied to a stream without orientation, the
stream becomes a wide-oriented stream. Similarly, once a byte input/output function has
been applied to a stream without orientation, the stream becomes a byte-oriented stream.
Only a call to the freopen function or the fwide function can otherwise alter the
orientation of a stream. (A successful call to freopen removes any orientation.)
Byte input/output functions shall not be applied to a wide-oriented stream and wide
character input/output functions shall not be applied to a byte-oriented stream.
Как расширить размер с сохранением данных(realloc) с массивом string в с++
Может ли прерывание прервать выполнение конструктора / деструктора в С++?
нужно ли в конструкторах / деструкторах защищать код критическими секциями?
в чем ее суть
как с ней бороться
if(rank == 0){
for(size_t i = 1; i < size; i++){
size
частей, и скорректировать для size - 1
. Почему можно не указывать virtual в файле реализации?
Почему виснет программа на MPI?
if(rank == 0){
for(int i = 0; i < VEC_SIZE; i++){
…
}
for (int i = 1; i < size; ++i) {
int q = -1;
MPI_Send(&q, 1, MPI_INT, i, 0, MPI_COMM_WORLD);
}
}else{
for (;;) {
int index;
MPI_Status status;
MPI_Recv(&index, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
if (index < 0)
break;
…
}
};
for(size_t i = 0; i < VEC_SIZE; i++){ size_t num_process = (i % (size - 1)) + 1; MPI_Send(&i, 1, MPI_INT, static_cast<int>(num_process), 0, MPI_COMM_WORLD);
size_t i
может отличаться от размера int
, подразумеваемого типом MPI_INT
. Этот код точно будет работать неправильно на big-endian архитектурах с LP64 ABI. Не работает деструктор