Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Using comptime function that require option will end in declaration loop

Aberta
#797 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
22/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Domínio
embedded-iot

Direção de pesquisa

The payload names no file paths. Start from the DMA function in the snippet and from where microzig_options redefines std_option, since the declaration loop comes from that shadowing. Reproduce by putting a DMA_Handler that calls std.fmt.comptimePrint inside microzig_options. Done means that build compiles without the declaration loop error, or the issue records why the shadowed std_option cannot be avoided.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

enhancement

Microzig redefine the std_option with specific entry for embedded device. Like interrupt or chip/hal config.
By doing so it allow users to fine tune the MCU. This have some limitation on how microzig_options can be initialized.

std_option is being shadow and whenever attribute inside the microzig_options need std_option it will trigger a declaration loop error.

This happen for example when you want to format string:

pub fn DMA(index: u32, channel: u32) type {

    // /!\   This line will trigger the declaration loop if you include the DMA_Handler
   // inside the microzig_option since this comptimePrint needs std_option.
    const interrupt_name = std.fmt.comptimePrint("DMA{}_Channel{}", .{ index, ch});
    const interrupt_index = blk: for (microzig.chip.interrupts) |*interrupt| {
        if (std.mem.eql(u8, interrupt_name, interrupt.name)) {
            break :blk interrupt.index;
        }
    } else @panic("Interrupt index not found");

    return struct {
        var channel: ?Channel = null;

        pub fn DMA_Handler() callconv(.c) void {
            const event = read_events();
            clear_events(event);
            if (channel) |*init_chan| {
                init_chan.deliver_event(event);
            }
        }
       ...
    }
 ...
}
Linguagem predominante
Zig
Estrelas
2.3k
Forks
198
Merge médio
1d 8h
PRs com merge (30d)
37

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de ZigEmbeddedGroup/microzig

Todas as issues de ZigEmbeddedGroup/microzig

Issues semelhantes

Mais issues de Embedded & IoT

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.