Похожие чаты

How can I use the macro cfg!() for multiple platforms

in same time?

Something like
#[cfg(target_os = ("linux", "macos"))]

7 ответов

17 просмотров

won't #[cfg(unix)] work for your case?

Jacob- Автор вопроса
Artem Starikov
won't #[cfg(unix)] work for your case?

No, it doesn't work on ubuntu, and in general I'm looking for this solution for other macros as well

Jacob
No, it doesn't work on ubuntu, and in general I'm ...

wdym it doesn't work on ubuntu? ubuntu is linux, hence is unix if you really want to say "only on linux or macos", you can use #[cfg(any(target_os = "linux", target_os = "macos")], see https://doc.rust-lang.org/reference/conditional-compilation.html

Jacob- Автор вопроса
Artem Starikov
wdym it doesn't work on ubuntu? ubuntu is linux, h...

Looks great thank you. following that question, does it possible to make block of code after that? like #[cfg(something)] { const SOME_STATIC = ...; const ANOTHER_STATIC = ...; }

Jacob- Автор вопроса
Jacob
screenshot Yes

on the top level, you'll have to apply the cfg to each item separately, sadly

Похожие вопросы

Обсуждают сегодня

А еще в перле можно уже @arr1 + @arr2?
Sergei Zhmylove
53
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
Где в Астане можно купить мясо для шашлыков?
Dancing Іңұқәһүғө
21
I arrived here after a Chico Crypto show highlighted the project & the Team - the fact that the Team had a long history of successfully working with household names gave me e...
Banter is Bullish
1
Подскажите, где смотреть результат выполнения программы? Код: ;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, станда...
Егор Анелькин
5
Привет всем. появился вопрос. Разрабатываю сайт, в данный момент он запущен. Хостинг beget. Добавляю на сайт яндекс метрику с помощью полей client-settings (взято отсюда http...
Andrew
2
Добрый день подскажите пожалуйста может кто то сталкивался с ошибками Sentry 22.10.0 развернутым из helm чарт в Kubernetes? Изначально 3 дня назад очень стало много событий ух...
Tire4 Finist Devops
1
Ну чё, сегодня все в гавно?))
ᅠ🚀
20
;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, стандартный ;вызов процедуры ;option casemap:no...
Егор Анелькин
1
I've built a utility for embedding binaries in JSON. I created a helper for images. Does anyone know of any other "binary things" you often interact with in golang that's apar...
Eli Davis
11
Карта сайта